declare @tb table (col1 int)insert @tb select '1'
union all
select '2' 
union all
select '3'这张表 @tb 
有没有办法在不创建另外的表的情况下给他重新赋值?就好像给变量赋值一样

解决方案 »

  1.   

    --当表一样用
    declare @tb table (col1 int)
    insert @tb select '1'
    union all
    select '2'  
    union all
    select '3'
    update @tb set col1=10
    where col1=3
      

  2.   

    @tb 中有值
    col1
    1
    2
    3
    现在我想把它变成 成col1
    4
    5
    6但是不能另外在定义一个表  
      

  3.   

    declare @tb table (col1 int)insert @tb select '1'
    union all
    select '2'  
    union all
    select '3'update @tb
    set col1=col1+3select * from @tb
    (3 行受影响)(3 行受影响)
           col1
    -----------
              4
              5
              6(3 行受影响)
      

  4.   

    declare @tb table (col1 int)
    insert @tb select '1'
    union all
    select '2'  
    union all
    select '3'
    declare @i int
    set @i=3
    update @tb set col1=@i,@i=@i+1
    select * from @tb
    /*
    col1
    -----------
    4
    5
    6(3 個資料列受到影響)
    */
      

  5.   


    就是update语句的。恩。就这样