|
1
5
你的前提是错误的。其他变量也不会在每次遇到declare语句时重新初始化。
印刷品
|
|
|
2
4
如期而至
http://msdn.microsoft.com/en-us/library/ms187953.aspx
|
|
|
3
-1
虽然这是一个老帖子只是想添加我的意见 set nocount on
declare @tt int
set @tt =10
while @tt>0
begin
declare @i int=0
set @i = @i + 1
print @i
set @tt=@tt-1
end
Results:
1
1
1
1
1
1
1
1
1
1
|
|
|
4
-1
如果希望在每次执行循环时加载表变量。在循环内完成工作后,从@Tablevariable中删除。 |
|
John D · 需要为NULL或NOT NULL的WHERE子句 1 年前 |
|
Marc Guillot · 记录值时忽略冲突 1 年前 |
|
|
Fachry Dzaky · 正确使用ROW_NUMBER 1 年前 |
|
|
TriumphTruth · 从满足特定条件的数据集中选择1行 1 年前 |