Log in
::
Register
::
Not logged in
Home
Tags
Articles
Editorials
Stairways
Forums
Scripts
Videos
Blogs
QotD
Books
Ask SSC
SQL Jobs
Training
Authors
About us
Contact us
Newsletters
Write for us
Recent Posts
Recent Posts
Popular Topics
Popular Topics
Home
Search
Members
Calendar
Who's On
Home
»
Article Discussions
»
Article Discussions by Author
»
Discuss content posted by bitbucket
»
INTERSECT 2
30 posts, Page 1 of 3
1
2
3
»
»»
INTERSECT 2
Rate Topic
Display Mode
Topic Options
Author
Message
bitbucket-25253
bitbucket-25253
Posted Monday, June 18, 2012 8:55 PM
SSCertifiable
Group: General Forum Members
Last Login: Today @ 1:49 PM
Points: 5,122,
Visits: 20,362
Comments posted to this topic are about the item
INTERSECT 2
If everything seems to be going well, you have obviously overlooked something.
Ron
Please help us, help you -before posting a question please
read
Before posting a performance problem please
read
Post #1317704
vk-kirov
vk-kirov
Posted Tuesday, June 19, 2012 12:29 AM
Hall of Fame
Group: General Forum Members
Last Login: Thursday, June 13, 2013 8:50 PM
Points: 3,208,
Visits: 4,178
Thanks for the question.
There is one thing not mentioned in the explanation, but very important to keep in mind: the INTERSECT statement and the SELECT #4 do not always return the same results. If both tables #A and #B contain NULL values, the INTERSECT statement will return a NULL value in the result set, while the SELECT #4 won't.
This behavior is documented in Books Online (
http://msdn.microsoft.com/en-us/library/ms188055.aspx
)
EXCEPT and INTERSECT (Transact-SQL)
Remarks
When you compare rows for determining distinct values, two NULL values are considered equal.
Post #1317741
Vera-428803
Vera-428803
Posted Tuesday, June 19, 2012 1:42 AM
Say Hey Kid
Group: General Forum Members
Last Login: Friday, May 10, 2013 5:25 AM
Points: 699,
Visits: 277
there is no GO after creation of table #B. In my opinion the select statements will fail with an error.
I didn't try it out but that's what I suspect.
Vera
Post #1317758
Koen Verbeeck
Koen Verbeeck
Posted Tuesday, June 19, 2012 2:14 AM
SSCrazy Eights
Group: General Forum Members
Last Login: Today @ 6:30 AM
Points: 9,410,
Visits: 6,495
Nice question, thanks. And thanks to vk-kirov for the remark.
How to post forum questions.
Need an answer? No, you need a question.
What’s the deal with Excel & SSIS?
Member of
LinkedIn
. My blog at
LessThanDot
.
MCSA SQL Server 2012 - MCSE Business Intelligence
Post #1317767
Koen Verbeeck
Koen Verbeeck
Posted Tuesday, June 19, 2012 2:27 AM
SSCrazy Eights
Group: General Forum Members
Last Login: Today @ 6:30 AM
Points: 9,410,
Visits: 6,495
Vera-428803 (6/19/2012)
there is no GO after creation of table #B. In my opinion the select statements will fail with an error.
I didn't try it out but that's what I suspect.
Vera
I think the statements will run just fine.
How to post forum questions.
Need an answer? No, you need a question.
What’s the deal with Excel & SSIS?
Member of
LinkedIn
. My blog at
LessThanDot
.
MCSA SQL Server 2012 - MCSE Business Intelligence
Post #1317772
Richard Warr
Richard Warr
Posted Tuesday, June 19, 2012 2:41 AM
SSCommitted
Group: General Forum Members
Last Login: Today @ 9:03 AM
Points: 1,634,
Visits: 1,152
All looked good to me - thanks for the question!
Any ideas on the performance differences between the INTERSECT and INNER JOIN methods?
Post #1317781
Stewart "Arturius" Campbell
Stewart "Arturius" Campbell
Posted Tuesday, June 19, 2012 3:17 AM
Hall of Fame
Group: General Forum Members
Last Login: Thursday, June 13, 2013 9:46 AM
Points: 3,157,
Visits: 4,341
Good question, thanks Ron
____________________________________________
Space, the final frontier? not any more...
All limits henceforth are self-imposed.
“libera tute vulgaris ex”
Post #1317803
marlon.seton
marlon.seton
Posted Tuesday, June 19, 2012 3:48 AM
Mr or Mrs. 500
Group: General Forum Members
Last Login: Today @ 2:07 AM
Points: 566,
Visits: 200
Richard Warr (6/19/2012)
All looked good to me - thanks for the question!
Any ideas on the performance differences between the INTERSECT and INNER JOIN methods?
I suspect the explain plans and performance will be identical.
Post #1317833
codebyo
codebyo
Posted Tuesday, June 19, 2012 4:00 AM
SSC Eights!
Group: General Forum Members
Last Login: Tuesday, June 04, 2013 8:50 AM
Points: 862,
Visits: 1,440
Great back-to-basics question and I got it wrong because I wasn't paying enough attention. Err...
I think there is a copy and paste mistake in SELECT #2 and SELECT #3 as both are the same code. I guess you meant one LEFT JOIN with the DISTINCT and the other without it, right?
BTW, thank you for the link with the article.
Best regards,
Andre Guerreiro Neto
Database Analyst
http://www.softplan.com.br
MCITPx1/MCTSx2
Post #1317844
Mighty
Mighty
Posted Tuesday, June 19, 2012 4:01 AM
SSCrazy
Group: General Forum Members
Last Login: Today @ 6:40 AM
Points: 2,746,
Visits: 991
I might overlook something, but aren't option 2 and 3 the same?
Post #1317845
« Prev Topic
|
Next Topic »
30 posts, Page 1 of 3
1
2
3
»
»»
Permissions
You
cannot
post new topics.
You
cannot
post topic replies.
You
cannot
post new polls.
You
cannot
post replies to polls.
You
cannot
edit your own topics.
You
cannot
delete your own topics.
You
cannot
edit other topics.
You
cannot
delete other topics.
You
cannot
edit your own posts.
You
cannot
edit other posts.
You
cannot
delete your own posts.
You
cannot
delete other posts.
You
cannot
post events.
You
cannot
edit your own events.
You
cannot
edit other events.
You
cannot
delete your own events.
You
cannot
delete other events.
You
cannot
send private messages.
You
cannot
send emails.
You
may
read topics.
You
cannot
rate topics.
You
cannot
vote within polls.
You
cannot
upload attachments.
You
may
download attachments.
You
cannot
post HTML code.
You
cannot
edit HTML code.
You
cannot
post IFCode.
You
cannot
post JavaScript.
You
cannot
post EmotIcons.
You
cannot
post or upload images.
Copyright © 2002-2013 Simple Talk Publishing. All Rights Reserved.
Privacy Policy.
Terms of Use.
Report Abuse.