Tuesday, July 13, 2010

EXCEPT to compare output of two queries

Very helpful SQL Server 2005+ commands:

http://weblogs.sqlteam.com/jeffs/archive/2007/05/02/60194.aspx

I had to find the different rows of two pretty complex, non-related queries, and decided to look up if there was an easier way to do than by exploiting UNION (a technique I think I picked up from the same author, actually...). Turns out you just need to put and EXCEPT in between the queries. That's it.

I just found this last week and have probably already used it five times. It makes me want to get a book on SQL Server 2008 to see what other time-savers I can find, especially I'm analyzing LOTS of data these days.

No comments: