Suchen Sie nach der easist/am skalierbarsten Möglichkeit, einen Satz "Unterschied" in SQL Server zu tun, siehe unten. SQL Server-Differenz (Gegenteil von Schnittmenge)
Wenn Sie nicht aus dem Bild sagen können, ich suche nach allem, was nicht in der Kreuzung ist.
ich eine Möglichkeit gesehen habe, es zu tun:
select * from (
(select 'test1' as a, 1 as b)
union all
(select 'test2' as a , 2 as b union all select 'test1' as a , 1 as b)
)un group by a,b having count(1)=1
aber ich fürchte, was passieren würde, wenn ich zwei große Mengen verwendet (ich werde nicht von den auserwählten ‚‘ konstanten Aussagen wird abfragt, werden meine Fragen ziehen von echten Tabellen)
EDIT:.
Mögliche Lösung ...
drop table #temp_a;
drop table #temp_b;
go
select * into #temp_a from (
select 1 as num, 'String' as two, 'int'as three, 'purple' as four union all
select 2 as num, 'dog' as two, 'int'as three, 'purple' as four union all
select 3 as num, 'dog' as two, 'int'as three, 'cat' as four) a
select * into #temp_b from (
select 1 as num, 'String' as two, 'decimal'as three, 'purple' as four union all
select 2 as num, 'dog' as two, 'int'as three, 'purple' as four union all
select 3 as num, 'dog' as two, 'int'as three, 'dog' as four) b
SELECT IsNull(a.num, b.num) A,IsNull(a.two, b.two) B, IsNull(a.three, b.three) C,
IsNull(a.four, b.four) D
FROM #temp_a a
FULL OUTER JOIN #temp_b b ON (a.num=b.num AND a.two=b.two and a.three=b.three and a.four=b.four)
WHERE (a.num is null or b.num is null )
ERGEBNISSE:
1 String int lila
3 Hund int Katze
1 String Dezember lila
3 Hund int Hund
Was bedeutet der IsNull Teil erreichen? Es ist nur ein Mittel zu "zeigen", was fehlt? – Nix
Für Zeilen, die nur einen Datensatz in einer der Tabellen enthalten (die gewünschten), wird in der einen oder anderen Tabelle eine Null angezeigt. Zum Beispiel ist entweder Table1.A null oder Table2.A wird für jede Zeile null sein. Der Isnull packt den Wert von der Seite, die einen Wert hat. – JohnFx