Различие SQL Server (противоположность пересечения)

Ниже вы найдете простой и наиболее масштабируемый способ сделать «разницу» в SQL Server.

Если вы не можете сказать по картинке, я ищу все, что не находится на перекрестке.

Я видел один способ сделать это:

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

Но я боюсь, что произойдет, если я буду использовать два больших набора (я не буду запрашивать из константных операторов select '', мои запросы будут извлекаться из реальных таблиц).

РЕДАКТИРОВАТЬ:

Возможное решение...

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  )

РЕЗУЛЬТАТЫ:

1 строка в фиолетовый

3 собаки в кошке

1 строка дека фиолетовый

3 собаки и собаки

Ответы на вопрос(3)

Ваш ответ на вопрос