March 28, 2008 09:28 PM

Set Operations

SQL Server 2005 Tips
Rating: (0)
SQL Server Magazine
InstantDoc ID #98159

Executive Summary:
SQL Server 2005 supports three set operations, called UNION, INTERSECT, and EXCEPT. Learn how to circumvent unsupported logical phases, work around SQL Server 2005’s lack of INTERSECT ALL and EXCEPT ALL, and take advantage of the INTERSECT and EXCEPT operations’ treatment of NULLs.


Set op...

...This article is for paid Professional Members only.

Already a Professional Member? Please log in now:

NOT A PROFESSIONAL MEMBER? YOU CHOOSE:

Professional Membership

Monthly

Annual

VIP Membership

Monthly

Annual

Add a Comment

excellent. useful.

Swati4/28/2008 9:26:54 PM


Exceptionally useful, even beyond Itzik's usual excellence!

Rho Trading4/7/2008 9:21:13 AM


Hi gitega,
Thanks so much for your feedback. Below is Itzik Ben-Gan's response to your questions.

“When the comparison columns are all that you need to return from a query, then yes, you can consider EXCEPT as an alternative to outer joins (or the NOT EXISTS predicate).
Just remember what I explained in the article in terms of the difference between EXCEPT and the alternatives in terms of NULL comparisons.

If you need to return also columns that you’re not comparing, a join gives you this option while a set operation doesn’t.

Cheers,
Itzik”

Please feel free to contact me if you have additional questions.

Megan Bearly
Associate Editor, SQL Server Magazine
mbearly@penton.com

meganbearly 4/7/2008 8:11:38 AM


Great article!

How would the outputs of EXCEPT statement differ from a left join when looking for rows that need to be inserted into target table ? OR Stated another way, is the EXCEPT statement an alternative to a LEFT JOIN in this use case (identify rows to insert to a target table)?

Lorrin4/4/2008 9:09:25 AM


You must log on before posting a comment.

Are you a new visitor? Register Here
GOOGLE LINKS
SPONSORED LINKS
FEATURED LINKS