Table A
id item_no
111 doing
116 doing
211 doingTable B
item_no
A001
A002
A003如何更新到Table A中???
Table A
id item_no
111 A001
116 A002
211 A003
id item_no
111 doing
116 doing
211 doingTable B
item_no
A001
A002
A003如何更新到Table A中???
Table A
id item_no
111 A001
116 A002
211 A003
set a.item_no = b.item_no
from a,b
where a.id = b.id
b表有ID吗?
create table tb(id int,item_no varchar(10))
insert into tb select 111,'doing'
union all select 116,'doing'
union all select 211,'doing'create table tt(item_no varchar(10))
insert into tt select 'A001'
union all select 'A002'
union all select 'A003'alter table tb add id_t int identity(1,1)
alter table tt add id_t int identity(1,1)
goupdate a set a.item_no=b.item_no from tb a,tt b where a.id_t=b.id_t
goalter table tb drop column id_t
alter table tt drop column id_t
goselect * from tb
select * from ttdrop table tb,tt