Reputation: 8936
This is confusing. For this declaration of the stored procedure:
CREATE PROCEDURE dbo.JobGet
@jobGuid uniqueidentifier = NULL,
This line returns results:
exec dbo.JobGet @jobGuid ='BDEA1E43-9EC7-42B0-A386-903FE1749FF7'
And this one does not:
exec sp_executesql N'dbo.JobGet',N'@jobGuid uniqueidentifier',@jobGuid='BDEA1E43-9EC7-42B0-A386-903FE1749FF7'
Can anyone explain why?
Upvotes: 3
Views: 540
Reputation: 138980
You need to add @jobGuid as a parameter when you call the SP. Without it the parameter will have the default value NULL
.
exec sp_executesql N'dbo.JobGet @jobGuid',
N'@jobGuid uniqueidentifier',
@jobGuid='BDEA1E43-9EC7-42B0-A386-903FE1749FF7'
Upvotes: 3