set @i=行号=@i+1 这是什么语法呀,等号可以连续赋值set @i=行号=@i+1本以为是错误的语法,自己测试了一下,竟然是正确的,我晕了,以前没见过这种语法呀?
drop table #tbcreate 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+1select *
from #tb

解决方案 »

  1.   

    http://topic.csdn.net/u/20101223/10/ffcc1e6f-92ce-4479-bf07-1de46bf2a9bf.html
    如果你能抽时间把精华帖都看一遍的话,就不会有这疑问了
      

  2.   


    update #tb set @i=行号=@i+1
    --等于
    update #tb set @i=行号,@id=@i+1
      

  3.   

    declare @i int
    set @i = 0
    update #tb set @i=行号=@i+1
    UPDATE
            { 
             table_name WITH ( < table_hint_limited > [ ...n ] )
             | view_name
             | rowset_function_limited
            } 
            SET
            { column_name = { expression | DEFAULT | NULL }
            | @variable = expression
            | @variable = column = expression } [ ,...n ]
      

  4.   

    反了 set 行号=@i,@id=@i+1
      

  5.   

    你就把它拆成@i=@i+1和行号=@i+1看就行了