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 1
23 posts, Page 1 of 3
1
2
3
»
»»
INTERSECT 1
Rate Topic
Display Mode
Topic Options
Author
Message
bitbucket-25253
bitbucket-25253
Posted Monday, June 11, 2012 8:39 PM
SSCertifiable
Group: General Forum Members
Last Login: Today @ 5:57 AM
Points: 5,122,
Visits: 20,366
Comments posted to this topic are about the item
INTERSECT 1
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 #1314179
Koen Verbeeck
Koen Verbeeck
Posted Monday, June 11, 2012 11:15 PM
SSCrazy Eights
Group: General Forum Members
Last Login: Yesterday @ 6:30 AM
Points: 9,410,
Visits: 6,495
Nice question.
Link to the INTERSECT page:
http://msdn.microsoft.com/en-us/library/ms188055(SQL.105).aspx
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 #1314196
Hugo Kornelis
Hugo Kornelis
Posted Tuesday, June 12, 2012 1:48 AM
SSCertifiable
Group: General Forum Members
Last Login: Today @ 10:45 AM
Points: 5,296,
Visits: 7,238
Thanks for the question, Ron. And thanks Koen for the extra link.
In case someone is wondering why the different data types have no effect - Ron included the relevant link, but didn't explicitly describe this in his explanation, so I will. The data types are compared to find the one with the highest precedence. It's char(2) vs bigint, so if you check Ron's link, you'll see that bigint wins. SQL Server then checks to see if implicit conversion is allowed for char to biging; this is the case, so the query compiles and a plan is created. During execution time, all char(2) values are converted to bigint, and then the INTERSECT operation is carried out.
If you change one of the values in the char(2) column to be something that doesn't convert to biging (e.g. 'a'), you'll get a run-time error.
Hugo Kornelis, SQL Server MVP
Visit my SQL Server blog:
http://sqlblog.com/blogs/hugo_kornelis
Post #1314251
Stewart "Arturius" Campbell
Stewart "Arturius" Campbell
Posted Tuesday, June 12, 2012 1:59 AM
Hall of Fame
Group: General Forum Members
Last Login: Today @ 8:26 AM
Points: 3,164,
Visits: 4,344
Nice question, thanks, Ron.
____________________________________________
Space, the final frontier? not any more...
All limits henceforth are self-imposed.
“libera tute vulgaris ex”
Post #1314258
bitbucket-25253
bitbucket-25253
Posted Tuesday, June 12, 2012 2:33 AM
SSCertifiable
Group: General Forum Members
Last Login: Today @ 5:57 AM
Points: 5,122,
Visits: 20,366
Hugo Kornelis (6/12/2012)
Thanks for the question, Ron. And thanks Koen for the extra link.
In case someone is wondering why the different data types have no effect - Ron included the relevant link, but didn't explicitly describe this in his explanation, so I will. The data types are compared to find the one with the highest precedence. It's char(2) vs bigint, so if you check Ron's link, you'll see that bigint wins. SQL Server then checks to see if implicit conversion is allowed for char to biging; this is the case, so the query compiles and a plan is created. During execution time, all char(2) values are converted to bigint, and then the INTERSECT operation is carried out.
If you change one of the values in the char(2) column to be something that doesn't convert to biging (e.g. 'a'), you'll get a run-time error.
Thanks for the additional explanation which you have explaned in a clear simple manner something one does not often find in BOL ... I am sure it will be appreciated by all those who read your posting.
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 #1314275
Dalton Moore
Dalton Moore
Posted Tuesday, June 12, 2012 6:50 AM
SSC-Addicted
Group: General Forum Members
Last Login: Tuesday, May 28, 2013 6:23 AM
Points: 418,
Visits: 228
Thanks for the question!
Post #1314398
mohammed moinudheen
mohammed moinudheen
Posted Tuesday, June 12, 2012 7:56 AM
SSCrazy
Group: General Forum Members
Last Login: 2 days ago @ 10:29 PM
Points: 2,178,
Visits: 3,599
Good one.
Mohammed Moinudheen
Post #1314450
OzYbOi d(-_-)b
OzYbOi d(-_-)b
Posted Tuesday, June 12, 2012 8:33 AM
Ten Centuries
Group: General Forum Members
Last Login: Thursday, January 31, 2013 8:53 AM
Points: 1,176,
Visits: 778
Thanks for the question - cheers
Post #1314472
sestell1
sestell1
Posted Tuesday, June 12, 2012 8:55 AM
SSC Eights!
Group: General Forum Members
Last Login: Today @ 11:10 AM
Points: 856,
Visits: 1,278
Interesting! Thanks for the question, and thanks for the additional explaination of the type conversion Hugo!
Post #1314496
Revenant
Revenant
Posted Tuesday, June 12, 2012 9:05 AM
Hall of Fame
Group: General Forum Members
Last Login: Today @ 10:42 AM
Points: 3,510,
Visits: 2,590
A really good one - thanks, Ron!
Post #1314505
« Prev Topic
|
Next Topic »
23 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.