T1                T2
   A    B              C  
   1    null           33
   2    null           45
   3    null           46
   4    null           12
   5    null           34--->T1
       A    B
       1    33 
       2    45 
       3    46
       4    12 
       5    34
sql 语句怎么实现~~!????? 

解决方案 »

  1.   

    看错了. 以为是一个表,呵呵t2若只有这一个列,那只能这么做: 或者用游标.2005下可借助row_number()
    select aid=identity(int),* into #1 from t1
    select bid=identity(int),* into #2 from t2update a set b=c
    from #1 a
    inner join #2 b
    on a.id=bidupdate a set a.b=b.b
    from t1 a
    inner join # b
    on a.a=b.adrop table #1,#2
      

  2.   

    select aid=identity(int),* into #1 from t1
    select bid=identity(int),* into #2 from t2update a set b=c
        from #1 a
    inner join #2 b
        on aid=bid /*这里手误*/update a set a.b=b.b
        from t1 a
    inner join # b
        on a.a=b.adrop table #1,#2
      

  3.   

    update t1
    set b = t2.b
    from t1,t2 where t1.A = t2.Aor
    select A = identity(int,1,1),* into tmp from t2
    update t1
    set b = tmp.b
    from t1,tmp
    where t1.a = tmp.a
      

  4.   

    declare @tmp table(id int identity(1,1),c int)
    insert @tmp(c) select c from t2
    update t1 set b=(select c from @tmp where id=t1.a)
      

  5.   

    t1的a连续的话,也可以采用鸟儿的做法, 不连续,就没办法了.
    只能两个临时表(或双表变量), 或者一个临时表(或一个表变量)再配合  t1的a进行conut计数 . count计数更慢.