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?
You need to add @jobGuid as a parameter when you call the SP. Without it the parameter will have the default value
NULL.