Bitte meine Probe sehen, wie unten:Kann aktualisieren sich nicht in SQL Server 2008 R2
create table tbl1(cl1 int, cl2 varchar(10))
create table tbl2(cl1 int, cl2 varchar(10))
insert tbl1
select 1, 'a' union all
select 1, 'b' union all
select 1, 'c' union all
select 1, 'd' union all
select 1, 'e'
insert tbl2
select 1, '' union all
select 1, '' union all
select 1, 'c' union all
select 1, '' union all
select 1, 'a'
select * from tbl1
select * from tbl2
update b
set b.cl2 = a.cl2
from tbl1 a inner join tbl2 b on a.cl1=b.cl1
where b.cl2 = '' and a.cl2 not in (select cl2 from tbl2 where tbl2.cl1 = a.cl1)
Was ich will, ist es, alle leeren Wert bei Cl2 Spalte in tbl2 Tabelle zu aktualisieren, mit nicht Werte duplizieren.
Ich habe versucht, wie das Skript oben zu laufen, aber es hat nicht richtig funktioniert.
Bitte helfen Sie mir, die Lösung zu finden.
Danke.
Letzte Auswahl dient zum Einfügen von Daten nach tbl2. –