如何为GO
语句设置动态计数?
我收到以下错误:
A fatal scripting error occurred.Incorrect syntax was encountered while parsing Go.
当我尝试运行以下查询时:
Declare @count int
Select @count=COUNT(*) From Users
Insert Into #DummyUsers
Select * from Users where UserName = 'Sachin'
GO @Count
但是当我使用以下带有硬编码计数的查询时,同样可以正常工作。
Declare @count int
Select @count=COUNT(*) From Users
Insert Into #DummyUsers
Select * from Users where UserName = 'Sachin'
GO 5
如果您对此有任何想法,请感谢您的建议。
最佳答案
你不能。一旦 SSMS 遇到 GO,批处理就会终止,您的变量将不再存在。
关于sql - 如何执行带动态计数的GO语句?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28972649/