如果有相关的ID  可以用
update   table1   set   xm=b.xm   from   table1  a,table2  b      where   a.id=b.id
可是我这两个表  没有相关的字段  
用下面的语句 好像更新不了update   table1   set   xm=b.xm   from   table1  a,table2  b 

解决方案 »

  1.   

    我目的是想实现  替换字段比如  字段 a,b   换成字段b,a 就是 字段a的值  全部换成  字段b
      

  2.   


    那你更新什么 。。
    --SQL2005,依次对应更新
    with cte as
    (
     select k.xm,o.xm 
     from 
    (select rn=ROW_NUMBER()over(order by getdate()),xm from table1 ) k join
     (select rn=ROW_NUMBER()over(order by getdate()),xm from table2 )  o on k.rn=o.rn
    )update cte 
    set k.xm=o.xm
      

  3.   


    with cte as
    (
     select k.a,o.b 
     from 
    (select rn=ROW_NUMBER()over(order by getdate()),xm from table1 ) k join
     (select rn=ROW_NUMBER()over(order by getdate()),xm from table2 )  o on k.rn=o.rn
    )update cte 
    set b=a
      

  4.   

    有没有sql2000, 最好access的语句啊 哈>>>>>>>>>>>>>>
    表1                   表2
    字段a                  字段b
    1                      a
    2                      b
    3                      c
    4                      d效果就是
    表1                   表2
    字段a                  字段b
    1                      1
    2                      2
    3                      3
    4                      4
      

  5.   

    select id=identity(int),* into #t1 from 表1
    select id=identity(int),* into #t2 from 表2update #t2 set 字段b=b.字段a from #t1 a,#t2 b where a.id=b.id
      

  6.   

    select identity(int,1,1),* into #1 from table1
    select identity(int,1,1),* into #2 from table2update #2
    set b=#1.a
    from #1 
    where #1.id=#2.id truncate table2
    insert table2 select b from #2 
      

  7.   

    访问access里面  有 什么替换select identity(int,1,1) 好像不支持啊