我在存储过程中使用“设置RowCount”。我有一个问题,Set RowCount的范围是什么?考虑以下SP
CREATE PROC Test AS BEGIN SET ROWCOUNT 10 ........... SET ROWCOUNT 0 END CREATE PROC Test2 AS BEGIN ........... SET ROWCOUNT 0 END CREATE PROC Test3 AS BEGIN SET ROWCOUNT 10 ........... END CREATE PROC Test4 AS BEGIN SET ROWCOUNT 10 SET ROWCOUNT 5 ........... SET ROWCOUNT 0 END
现在在上面的SP中,您必须看到我的SetRowcount语句不匹配。所以我的问题是,如果我忘记在开头的“ Set RowCount N”语句中添加“ Set RowCount 0”,该怎么办?需要吗?这会影响我的应用程序中其余SP的执行吗?
据我所知,与注释中链接的问题所接受的答案相反,我所看到的范围规则与#temp表可见性完全相同。它传播到子批次,但是当批次退出时,它将重置为先前的值。
#temp
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