sql code :
declare @id int
set @id = 0
select top 1 @id = id from userMsg
print @id
select top 0 @id = id from userMsg
print @id
output :
declare @id int
set @id = 0
select top 1 @id = id from userMsg
print @id
select top 0 @id = id from userMsg
print @id
output :
1
1
由此可见,T-SQL执行select赋值后,如果没有选取到值,则变量保持原来的值不变。
没有评论:
发表评论