T1 T2
A B C
1 null 33
2 null 45
3 null 46
4 null 12
5 null 34--->T1
A B
1 33
2 45
3 46
4 12
5 34
sql 语句怎么实现~~!?????
A B C
1 null 33
2 null 45
3 null 46
4 null 12
5 null 34--->T1
A B
1 33
2 45
3 46
4 12
5 34
sql 语句怎么实现~~!?????
select aid=identity(int),* into #1 from t1
select bid=identity(int),* into #2 from t2update a set b=c
from #1 a
inner join #2 b
on a.id=bidupdate a set a.b=b.b
from t1 a
inner join # b
on a.a=b.adrop table #1,#2
select bid=identity(int),* into #2 from t2update a set b=c
from #1 a
inner join #2 b
on aid=bid /*这里手误*/update a set a.b=b.b
from t1 a
inner join # b
on a.a=b.adrop table #1,#2
set b = t2.b
from t1,t2 where t1.A = t2.Aor
select A = identity(int,1,1),* into tmp from t2
update t1
set b = tmp.b
from t1,tmp
where t1.a = tmp.a
insert @tmp(c) select c from t2
update t1 set b=(select c from @tmp where id=t1.a)
只能两个临时表(或双表变量), 或者一个临时表(或一个表变量)再配合 t1的a进行conut计数 . count计数更慢.