You are here: Re: finding mismatched rows between identical tables based on 2 or more cols « MsSQL Server « IT news, forums, messages
Re: finding mismatched rows between identical tables based on 2 or more cols

Posted by Plamen Ratchev on 06/10/07 03:13

Here are two different approaches:

-- SQL Server 2005 only.
SELECT ColA, ColB FROM RS_A
EXCEPT
SELECT ColA, ColB FROM RS_B;

-- SQL Server 2000.
SELECT ColA, ColB FROM
( SELECT 'A' AS Source, ColA, ColB
FROM RS_A
UNION ALL
SELECT 'B' AS Source, ColA, ColB
FROM RS_B ) AS T
GROUP BY ColA, ColB
HAVING COUNT(*) = 1 AND MIN(Source) = 'A'

HTH,

Plamen Ratchev
http://www.SQLStudio.com

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация