August 3, 2010 at 10:05 am
Hi All,
If I have a stored proc and I SET NOCOUNT ON and later on I also
EXEC some dynamic SQL do I have to also pass SET NOCOUNT ON in the Dynamic SQL?
Regards,
OutOfTOuch
August 3, 2010 at 10:21 am
No you don't need to.
Test this:
declare @sql nvarchar(1000)
set @sql = 'select count(*) from sys.objects'
exec sp_executesql @sql
and then this:
set nocount on
declare @sql nvarchar(1000)
set @sql = 'select count(*) from sys.objects'
exec sp_executesql @sql
Scope of "set nocount on" is a connection session (spid)
August 3, 2010 at 4:33 pm
Thank You! This is Key: "Scope of "set nocount on" is a connection session (spid)"
Do you know if SQLBOL says this anywhere?
August 4, 2010 at 3:45 am
No, actually BOL doesn't tell anything about it in the "SET NOCOUNT" article. However you can find the list of SET statements of the session scope:
August 4, 2010 at 9:35 am
Thanks Again!
Viewing 5 posts - 1 through 5 (of 5 total)
You must be logged in to reply to this topic. Login to reply