日期:2014-05-16 浏览次数:21020 次
select dtype INTO #tmptble from table2 where uid in (select uid from table2) update table1 set dtype=(select top 1 dtype from #tmptble where table1.uid=#tmptble.uid)
------解决方案--------------------
楼上有误。
select dtype INTO #tmptble from table2 where uid in (select uid from [color=#FF0000]table1[/color]) update table1 set dtype=(select top 1 dtype from #tmptble where table1.uid=#tmptble.uid)
------解决方案--------------------
create table tab1_uid as
select distinct uid from table1;
create index idx1 on tab1_uid(uid);
create table tab2_uid as
select a.uid , a.dtype
from table2 a inner join tab1_uid b on a.uid = b.uid
update table1 a, tab2_uid b
set a.dtype = b.dtype
where a.uid = b.uid