34,874
社区成员
发帖
与我相关
我的任务
分享
drop table #tb
create table #tb(autoid int identity(581080,1),行号 int,b varchar(10))
insert #tb (b)
select 'aaa' union all
select 'bbb' union all
select 'ccc' union all
select 'ddd' union all
select 'eee'
--以下代码为何执行正确呢?
-- set @i=行号=@i+1 这是什么语法呀,等号可以连续赋值
declare @i int
set @i = 0
update #tb set @i=行号=@i+1
select *
from #tb
set 行号=@i,@id=@i+1
update #tb set @i=行号=@i+1
--等于
update #tb set @i=行号,@id=@i+1