例如:update table set num=num+1 where id=**
能不能直接返回num

解决方案 »

  1.   


    --可以
    update hllbiao set id=id+1 where id=1; 
      

  2.   


    --2005+ try
    update table set num=num+1 where id=**
    output inserted.id,inserted.num
      

  3.   


    --更新完了以后再查一遍
    select num from table where id=**
      

  4.   

    string sql='update table set num=num+1 where id=**;select num from table where id=**'...
    SqlCommand cmd = New SqlCommand(sql, Conn);
    int num=cmd.ExecuteScalar() 
      

  5.   


    語法不正確,output 放在set后面改為update table 
    set num=num+1 
    output inserted.id,inserted.num 
    where id=1
      

  6.   

    update table set num=num+1 where id=**返回更新值,如果是多記錄時用臨時表或表變量如果是單一時用變量declare @i int
    update table set @i=num=num+1 where id=**
    select @i多記錄時declare @T Table(num int)
    update table set num=num+1 output inserted.num into @T where id=**
    select * from @T