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 12»»

MERGE with ANSI Expand / Collapse
Author
Message
Posted Thursday, November 24, 2011 11:31 PM


SSCertifiable

SSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiable

Group: General Forum Members
Last Login: Today @ 10:24 AM
Points: 5,977, Visits: 8,239
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
Post #1211805
Posted Friday, November 25, 2011 1:39 AM
SSC Eights!

SSC Eights!SSC Eights!SSC Eights!SSC Eights!SSC Eights!SSC Eights!SSC Eights!SSC Eights!

Group: General Forum Members
Last Login: Today @ 9:34 AM
Points: 842, Visits: 1,532
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...!
Post #1211844
Posted Friday, November 25, 2011 1:54 AM


Hall of Fame

Hall of FameHall of FameHall of FameHall of FameHall of FameHall of FameHall of FameHall of FameHall of Fame

Group: General Forum Members
Last Login: Today @ 5:18 AM
Points: 3,925, Visits: 5,112
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”
Post #1211854
Posted Friday, November 25, 2011 2:20 AM
Ten Centuries

Ten CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen Centuries

Group: General Forum Members
Last Login: Tuesday, July 9, 2013 11:12 PM
Points: 1,263, Visits: 1,081
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
Post #1211865
Posted Friday, November 25, 2011 2:37 AM
SSC Eights!

SSC Eights!SSC Eights!SSC Eights!SSC Eights!SSC Eights!SSC Eights!SSC Eights!SSC Eights!

Group: General Forum Members
Last Login: Today @ 8:06 AM
Points: 835, Visits: 2,446
My brain hurts...
Post #1211868
Posted Friday, November 25, 2011 2:41 AM
SSC Eights!

SSC Eights!SSC Eights!SSC Eights!SSC Eights!SSC Eights!SSC Eights!SSC Eights!SSC Eights!

Group: General Forum Members
Last Login: Today @ 9:34 AM
Points: 842, Visits: 1,532
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.
Post #1211870
Posted Friday, November 25, 2011 3:20 AM


SSCertifiable

SSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiable

Group: General Forum Members
Last Login: Today @ 10:24 AM
Points: 5,977, Visits: 8,239
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! 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!



Hugo Kornelis, SQL Server MVP
Visit my SQL Server blog: http://sqlblog.com/blogs/hugo_kornelis
Post #1211883
Posted Friday, November 25, 2011 9:11 AM


SSCrazy Eights

SSCrazy EightsSSCrazy EightsSSCrazy EightsSSCrazy EightsSSCrazy EightsSSCrazy EightsSSCrazy EightsSSCrazy EightsSSCrazy EightsSSCrazy Eights

Group: General Forum Members
Last Login: Today @ 8:48 AM
Points: 8,739, Visits: 9,287
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
Post #1212003
Posted Friday, November 25, 2011 9:20 AM


SSCrazy Eights

SSCrazy EightsSSCrazy EightsSSCrazy EightsSSCrazy EightsSSCrazy EightsSSCrazy EightsSSCrazy EightsSSCrazy EightsSSCrazy EightsSSCrazy Eights

Group: General Forum Members
Last Login: Today @ 8:48 AM
Points: 8,739, Visits: 9,287
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
Post #1212005
Posted Friday, November 25, 2011 11:57 AM


Hall of Fame

Hall of FameHall of FameHall of FameHall of FameHall of FameHall of FameHall of FameHall of FameHall of Fame

Group: General Forum Members
Last Login: Friday, August 29, 2014 10:23 AM
Points: 3,299, Visits: 1,978
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!
Post #1212049
« Prev Topic | Next Topic »

Add to briefcase 12»»

Permissions Expand / Collapse