Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
 
Log in  ::  Register  ::  Not logged in
 
 
 
        
Home       Members    Calendar    Who's On


Add to briefcase «««56789

Intersect, Except, Union, All and Any Expand / Collapse
Author
Message
Posted Friday, December 23, 2011 8:32 AM
SSC Journeyman

SSC JourneymanSSC JourneymanSSC JourneymanSSC JourneymanSSC JourneymanSSC JourneymanSSC JourneymanSSC Journeyman

Group: General Forum Members
Last Login: Monday, December 16, 2013 7:19 AM
Points: 98, Visits: 226
Note: I am an old curmudgeon who speaks bluntly. Nothing that follows is a personal attack. I just see this as a teachable moment.
So:

Let me get this straight:
You stumbled over some new features.
You glanced at books online
You put together some trivial tests against a trivial database
You decide you are now enough of an expert to write an article about it
You write an article that spends more time comparing the performance of trivial tests to six decimal places than into what they actually do.

If you had spent even a few minutes on Google or Wikipedia you would have learned a lot and been in a position to write a useful article.
Instead you went on the assumption that if you could find good uses for the features then there were no good uses for them. I will let you supply the adjective for that attitude.

To everyone who thought it was a great article:
It was a good topic to bring up, but did you read the other comments before you added yours?
Post #1226279
Posted Friday, December 23, 2011 11:36 AM
SSCrazy

SSCrazySSCrazySSCrazySSCrazySSCrazySSCrazySSCrazySSCrazy

Group: General Forum Members
Last Login: 2 days ago @ 10:32 AM
Points: 2,905, Visits: 1,825
Let me get this straight:
You stumbled over some new features.

CORRECT. In the Microsoft course material


You glanced at books online

Did a bit more than glance and also read what little was available in 2009. Not sure when the Wikipedia article originated as it doesn't have an original date, only a modified date in 2011.

I read BOL and the Microsoft course notes plus the standard Googling. What was available looked very like the "Other editions SQL2005" version on BOL.


You put together some trivial tests against a trivial database


CORRECT. I did say it was Adventureworks. The whole point of using Adventureworks is that is a publicly available database. Any tests or experiments run on Adventureworks can be easily repeated and therefore verified by developers and DBAs of all levels of ability.



You decide you are now enough of an expert to write an article about it


No, I was asked by the people being put through the course what these operators were and as I hadn't seen them before I did some digging and basic experimenting.

As with any experiment
1. Document the experiment so it is repeatable and up for critique.
2. Document the results so they are verifiable

I don't have the attitude of expecting people to bask in my magnificence. I'm not that arrogant.
What I want to achieve in any article
1. Pass on what I have learnt to those coming up the ranks being very clear about my methods and experiments
2. Provoke response from the many ahead of me in the ranks so that I learn more.

Actually the forum responses did teach me something

select fieldlist from OriginalSource query Where qualifying criteria is met
intersect
select fieldlist from Targettable

Very useful in data warehouse reconcilliation.

I was arrogant enough to think that I could add some clarity to BOL.



Instead you went on the assumption that if you could find good uses for the features then there were no good uses for them.


I can't recall making that assumption, it certainly doesn't say anything about assumptions in the article?

Again the article and results are up for critique and as per the responses in the forum the true use for these operators was revealled.


I will let you supply the adjective for that attitude.


I don't have that attitude, never have had, never will have. You are very much holding the wrong end of the stick and no, I am not making the assumption that it is a stick in your hand.

Merry Christmas


LinkedIn Profile
Newbie on www.simple-talk.com
Post #1226343
Posted Friday, December 23, 2011 11:17 PM
SSC Rookie

SSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC Rookie

Group: General Forum Members
Last Login: Thursday, August 22, 2013 8:19 AM
Points: 38, Visits: 17
My use of Except, Intersect is to prepare a slowly changing dimension table as written below. This will help me to get the changed address as well as new records. How can i re-write this in sql without EXCEPT operand

SELECT CustomerID, Address1, District, Phone1, Phone2,....some 50 col FROM CustAddress_OLTP
EXCEPT
SELECT CustomerID, Address1, District, Phone1, Phone2,....some 50 col FROM CustAddress_SCD
Post #1226409
Posted Saturday, December 24, 2011 8:27 AM


SSC-Enthusiastic

SSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-Enthusiastic

Group: General Forum Members
Last Login: Saturday, August 30, 2014 6:38 PM
Points: 107, Visits: 666
I've actually used INTERSECT and EXCEPT quite a bit, not as a replacement for inner joins as some of these comments imply, but to simplify the comparison of two complex resultsets.

I've also used INTERSECT as a performance tweak:
http://www.real-sql-guy.com/2011/11/stop-performance-problem-with-intersect.html
Post #1226460
Posted Saturday, December 24, 2011 11:44 AM
Grasshopper

GrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopper

Group: General Forum Members
Last Login: Friday, August 8, 2014 10:34 PM
Points: 13, Visits: 52
Thanks for taking the time to create this post. I have often asked myself if there was any advantage in using some of these commands.
Post #1226485
Posted Monday, December 26, 2011 10:00 AM
Valued Member

Valued MemberValued MemberValued MemberValued MemberValued MemberValued MemberValued MemberValued Member

Group: General Forum Members
Last Login: Tuesday, March 27, 2012 7:17 AM
Points: 51, Visits: 167
I agree. I have found 'excep't very useful when many columns are involved in a table and I want to exclude one entire table from the other. I think you will find in that case except will outperform a join or a not in statement. At least that is what I found on sql2008 r1
Post #1226680
Posted Thursday, March 22, 2012 7:43 AM
SSC Rookie

SSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC Rookie

Group: General Forum Members
Last Login: Tuesday, July 8, 2014 2:17 PM
Points: 34, Visits: 161
I really liked this article - very thorough. EXCEPT seems to be an analog to the Oracle MINUS, so sometimes I like it because I feel like I really know what's happening there (Oracle SQL being my first SQL language). But, my alternative is to use NOT EXISTS, so I wonder if you would consider expanding this to include the EXISTS/NOT EXISTS alternatives? I'm curious to see how they stack up within your example stream.

In general, I really liked the approach and illustrations (both pictoral and logical).

Thank you --

Donna
Post #1270852
« Prev Topic | Next Topic »

Add to briefcase «««56789

Permissions Expand / Collapse