I am using \"Set RowCount\" in my Stored Procedures. I have one question, what is the scope of Set RowCount ? Consider the below SPs
CREATE PROC Test
AS
Contrary to the accepted answer in the question linked to in the comments as far as I can see the scope rules for this are exactly the same as those for #temp
table visibility. It propagates to child batches but when the batch exits it gets reset to the previous value.
CREATE PROC #bar
AS
SELECT * FROM sys.objects
EXEC ('SELECT * FROM sys.objects')
GO
CREATE PROC #foo
AS
SET ROWCOUNT 1
EXEC #bar
GO
SET ROWCOUNT 4
EXEC #foo /*Returns 2 resultsets with 1 row*/
EXEC #bar /*Returns 2 resultsets with 4 rows*/
DROP PROC #foo
DROP PROC #bar