Click here to monitor SSC
SQLServerCentral is supported by Redgate
 
Log in  ::  Register  ::  Not logged in
 
 
 


MERGE with ANSI


MERGE with ANSI

Author
Message
Hugo Kornelis
Hugo Kornelis
SSCrazy Eights
SSCrazy Eights (8.3K reputation)SSCrazy Eights (8.3K reputation)SSCrazy Eights (8.3K reputation)SSCrazy Eights (8.3K reputation)SSCrazy Eights (8.3K reputation)SSCrazy Eights (8.3K reputation)SSCrazy Eights (8.3K reputation)SSCrazy Eights (8.3K reputation)

Group: General Forum Members
Points: 8339 Visits: 11585
Comments posted to this topic are about the item MERGE with ANSI


Hugo Kornelis, SQL Server MVP
Visit my SQL Server blog: http://sqlblog.com/blogs/hugo_kornelis
martin.whitton
martin.whitton
Ten Centuries
Ten Centuries (1.3K reputation)Ten Centuries (1.3K reputation)Ten Centuries (1.3K reputation)Ten Centuries (1.3K reputation)Ten Centuries (1.3K reputation)Ten Centuries (1.3K reputation)Ten Centuries (1.3K reputation)Ten Centuries (1.3K reputation)

Group: General Forum Members
Points: 1289 Visits: 1763
Given the MERGE statement below, which is completely correct for SQL Server 2005 and later


The MERGE statement is only available in SQL Server 2008 and later.

I don't think this has any bearing on the low percentage of people getting this right, though...!
Stewart "Arturius" Campbell
Stewart "Arturius" Campbell
SSCertifiable
SSCertifiable (5.8K reputation)SSCertifiable (5.8K reputation)SSCertifiable (5.8K reputation)SSCertifiable (5.8K reputation)SSCertifiable (5.8K reputation)SSCertifiable (5.8K reputation)SSCertifiable (5.8K reputation)SSCertifiable (5.8K reputation)

Group: General Forum Members
Points: 5812 Visits: 7140
This was quite a tough one.
Learned a fair bit about the origin of the MERGE statement from this.

Took a fair amount of thinking and digging to get it, though.
I think the main reason for the poor score rate is that the SQL ANSI:2003 definitions are not readily available.

____________________________________________
Space, the final frontier? not any more...
All limits henceforth are self-imposed.
“libera tute vulgaris ex”
michael.kaufmann
michael.kaufmann
Ten Centuries
Ten Centuries (1.3K reputation)Ten Centuries (1.3K reputation)Ten Centuries (1.3K reputation)Ten Centuries (1.3K reputation)Ten Centuries (1.3K reputation)Ten Centuries (1.3K reputation)Ten Centuries (1.3K reputation)Ten Centuries (1.3K reputation)

Group: General Forum Members
Points: 1293 Visits: 1082
Stewart "Arturius" Campbell (11/25/2011)
This was quite a tough one.
Learned a fair bit about the origin of the MERGE statement from this.

I definitely second this.

Some may argue it's cheating to do some reading (researching) prior to answering the QotD, but I came across this interesting and helpful blog post by one Hugo Kornelis :-).

Hence a double thank you to Hugo for an excellent QotD on MERGE following the ANSI standard, and for sharing your extensive knowledge with everybody on the web.

You all have a great weekend,
Michael
adb2303
adb2303
SSC Eights!
SSC Eights! (962 reputation)SSC Eights! (962 reputation)SSC Eights! (962 reputation)SSC Eights! (962 reputation)SSC Eights! (962 reputation)SSC Eights! (962 reputation)SSC Eights! (962 reputation)SSC Eights! (962 reputation)

Group: General Forum Members
Points: 962 Visits: 2886
My brain hurts...
martin.whitton
martin.whitton
Ten Centuries
Ten Centuries (1.3K reputation)Ten Centuries (1.3K reputation)Ten Centuries (1.3K reputation)Ten Centuries (1.3K reputation)Ten Centuries (1.3K reputation)Ten Centuries (1.3K reputation)Ten Centuries (1.3K reputation)Ten Centuries (1.3K reputation)

Group: General Forum Members
Points: 1289 Visits: 1763
I came across this interesting and helpful blog post by one Hugo Kornelis :-).

Hence a double thank you to Hugo for an excellent QotD on MERGE following the ANSI standard, and for sharing your extensive knowledge with everybody on the web.l


Thank you Michael (and Hugo!) for that very useful link.

Despite my minor bit of pedantry about the SQL versions, I second your thanks to Hugo - I always read his contributions with interest and often learn from them. :-)
Hugo Kornelis
Hugo Kornelis
SSCrazy Eights
SSCrazy Eights (8.3K reputation)SSCrazy Eights (8.3K reputation)SSCrazy Eights (8.3K reputation)SSCrazy Eights (8.3K reputation)SSCrazy Eights (8.3K reputation)SSCrazy Eights (8.3K reputation)SSCrazy Eights (8.3K reputation)SSCrazy Eights (8.3K reputation)

Group: General Forum Members
Points: 8339 Visits: 11585
Thanks, all, for the kind words! I am glad you all find my questions entertaining and informative.

martin.whitton (11/25/2011)
The MERGE statement is only available in SQL Server 2008 and later.

Oops! Blush Stupid mistake - sorry 'bout that!

Stewart "Arturius" Campbell (11/25/2011)
I think the main reason for the poor score rate is that the SQL ANSI:2003 definitions are not readily available.

I included a link to a freely available version (of a late draft, not the official final version) in the answer's explanation. When I first found this link, I immediately downloaded it to my computer for fear of it being removed. When I submitted the question, I had to use Google to re-find the link.
As far as I know, there are no newer versions of the ANSI SQL standard that are freely available (unfortunately).

By the way - after submitting this question, I found that most of the non-SQL:2003 stuff in MERGE was not added by Microsoft for SQL Server only, but is defined in SQL:2008. So I was very glad that I included the version of the standard in the question! :-D


Hugo Kornelis, SQL Server MVP
Visit my SQL Server blog: http://sqlblog.com/blogs/hugo_kornelis
TomThomson
TomThomson
SSChampion
SSChampion (10K reputation)SSChampion (10K reputation)SSChampion (10K reputation)SSChampion (10K reputation)SSChampion (10K reputation)SSChampion (10K reputation)SSChampion (10K reputation)SSChampion (10K reputation)

Group: General Forum Members
Points: 10765 Visits: 12019
Good question and good explanation - and thanks especially for the link to a late draft of the SQL 2003 standard.

It was a bit hard for a Friday question, just when people are getting ready to relax for the weekend (careless scheduling by Steve there, or did he do it on purpose?). I spent a long time racking my brain to try to remember which was the fourth box to tick - after I had ticked three boxes all the others seemed as if they ought to be left unticked; and then I clicked that only UPDATE was allowed in WHEN MATCHED, not DELETE, so as I had already ticked WHEN NOT MATCHED BY SOURCE I logically had to tick DELETE as my fourth choice.

Definitely good excercise for the grey matter.

Tom

TomThomson
TomThomson
SSChampion
SSChampion (10K reputation)SSChampion (10K reputation)SSChampion (10K reputation)SSChampion (10K reputation)SSChampion (10K reputation)SSChampion (10K reputation)SSChampion (10K reputation)SSChampion (10K reputation)

Group: General Forum Members
Points: 10765 Visits: 12019
martin.whitton (11/25/2011)
The MERGE statement is only available in SQL Server 2008 and later.

I don't think this has any bearing on the low percentage of people getting this right, though...!

Actually the percentage doesn't seem too bad - up to now 12% got it right; that's a bit more than four times as many as would be expected if everyone ticked 4 boxes chosen at random from the seven boxes provided. There have been much worse responses to other questions.

But I agree this one was pretty hard.

Tom

Ken Wymore
Ken Wymore
SSCarpal Tunnel
SSCarpal Tunnel (4.4K reputation)SSCarpal Tunnel (4.4K reputation)SSCarpal Tunnel (4.4K reputation)SSCarpal Tunnel (4.4K reputation)SSCarpal Tunnel (4.4K reputation)SSCarpal Tunnel (4.4K reputation)SSCarpal Tunnel (4.4K reputation)SSCarpal Tunnel (4.4K reputation)

Group: General Forum Members
Points: 4444 Visits: 2342
Nice question Hugo, had to do some research before answering this one and I still was surprised that I got it right. I think my brain now hurts too much to get anything else done today. Happy Friday!
Go


Permissions

You can't post new topics.
You can't post topic replies.
You can't post new polls.
You can't post replies to polls.
You can't edit your own topics.
You can't delete your own topics.
You can't edit other topics.
You can't delete other topics.
You can't edit your own posts.
You can't edit other posts.
You can't delete your own posts.
You can't delete other posts.
You can't post events.
You can't edit your own events.
You can't edit other events.
You can't delete your own events.
You can't delete other events.
You can't send private messages.
You can't send emails.
You can read topics.
You can't vote in polls.
You can't upload attachments.
You can download attachments.
You can't post HTML code.
You can't edit HTML code.
You can't post IFCode.
You can't post JavaScript.
You can post emoticons.
You can't post or upload images.

Select a forum

































































































































































SQLServerCentral


Search