insert b(img字段) select img字段 from a

解决方案 »

  1.   

    我需要用update的方式。
    请问如何做?
      

  2.   

    --测试--测试表
    create table a(id int identity(1,1),img image)
    insert a  select 0xa32543525435435
    union all select 0xe34545644564641
    gocreate table b(id int identity(1,1),img image)
    go--复制数据
    insert b(img) select img from a
    go--显示复制结果
    select * from b
    go--删除测试
    drop table a,b/*--测试结果id          img                         
    ----------- ----------------------------
    1           0x0A32543525435435
    2           0x0E34545644564641(所影响的行数为 2 行)
    --*/
      

  3.   

    update b set img=a.img
    from a,b 
    where a.id=b.id
      

  4.   

    --测试--测试表
    create table a(id int identity(1,1),img image)
    insert a  select 0xa32543525435435
    union all select 0xe34545644564641
    gocreate table b(id int identity(1,1),img image)
    insert b  select null
    union all select null
    go--更新方式
    update b set img=a.img
    from a,b 
    where a.id=b.id
    go--显示复制结果
    select * from b
    go--删除测试
    drop table a,b/*--测试结果id          img                         
    ----------- ----------------------------
    1           0x0A32543525435435
    2           0x0E34545644564641(所影响的行数为 2 行)
    --*/