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
update 表A set 某一字段=表B.某一字段 from 表A ,表B where 条件
update @a set string=a.string from @t a 最后一个a 是干嘛的
update @a set [email protected] from @t where ... --不挂也可以,后面where挂相应的条件
update 表A set 某一字段=表B.某一字段 from 表A ,表B where 表A.id=表B.id
update table1 set table1.字段=table2.字段 from table1 join table2 on table1.id=table2.id
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
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
from 表A ,表B
where 条件
最后一个a 是干嘛的
--不挂也可以,后面where挂相应的条件
from 表A ,表B
where 表A.id=表B.id
set table1.字段=table2.字段
from table1 join table2
on table1.id=table2.id
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