MERGE with ANSI

  • Comments posted to this topic are about the item MERGE with ANSI


    Hugo Kornelis, SQL Server/Data Platform MVP (2006-2016)
    Visit my SQL Server blog: https://sqlserverfast.com/blog/
    SQL Server Execution Plan Reference: https://sqlserverfast.com/epr/

  • 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...!

  • This was removed by the editor as SPAM

  • 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

  • My brain hurts...

  • 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. 🙂

  • 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! 😀


    Hugo Kornelis, SQL Server/Data Platform MVP (2006-2016)
    Visit my SQL Server blog: https://sqlserverfast.com/blog/
    SQL Server Execution Plan Reference: https://sqlserverfast.com/epr/

  • 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

  • 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

  • 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!

  • Tough one, thanks.

    Need an answer? No, you need a question
    My blog at https://sqlkover.com.
    MCSE Business Intelligence - Microsoft Data Platform MVP

  • A very tough question....

  • I have unbfair advantage: MERGE is my daily bread. 😉

    Thanks for this interesting question!

  • Thanks Hugo

    Jason...AKA CirqueDeSQLeil
    _______________________________________________
    I have given a name to my pain...MCM SQL Server, MVP
    SQL RNNR
    Posting Performance Based Questions - Gail Shaw[/url]
    Learn Extended Events

  • thanks Hugo!

Viewing 15 posts - 1 through 15 (of 16 total)

You must be logged in to reply to this topic. Login to reply