如题,sql如何写

解决方案 »

  1.   

    declare @t table(string varchar(10))
    insert into @t select 'aaa'declare @a table(string varchar(10))
    insert into @a select '1'update @a set string=a.string from @t a
    select * from @a
      

  2.   

    update 表A set 某一字段=表B.某一字段
    from 表A ,表B 
    where 条件
      

  3.   

    update @a set string=a.string from @t a
    最后一个a 是干嘛的
      

  4.   

    update @a set [email protected] from @t where ...
    --不挂也可以,后面where挂相应的条件
      

  5.   

    update 表A set 某一字段=表B.某一字段
    from 表A ,表B 
    where 表A.id=表B.id
      

  6.   

    update table1
    set table1.字段=table2.字段
    from table1 join table2
    on table1.id=table2.id
      

  7.   

    declare @t table(id int,string varchar(10))
    insert into @t select 1,'aaa'
    insert into @t select 2,'bbb'
    insert into @t select 3,'ccc'declare @a table(id int,string varchar(10))
    insert into @a select 1,'1'
    insert into @a select 2,'2'
    insert into @a select 3,'3'update b set b.string=a.string from @t a,@a b where a.id=b.id
    select * from @a