Merge - Pros and cons

  • Hi there,

    Please any one help me out to understand what is MERGE ? and when to use it?

    Also explain me the Pros and cons.

    Thanks in Advance

  • I gave a very good talk on MERGE that you can download here: http://sqlsaturday.com/217/schedule.aspx

    Note you can View All Events and open the schedule page for every SQL Saturday that has ever happened. Anything you see of interest is freely available content. It is some of the best free learning on the web about SQL Server!!

    Best,
    Kevin G. Boles
    SQL Server Consultant
    SQL MVP 2007-2012
    TheSQLGuru on googles mail service

  • Can you not even be bothered to type "TSQL MERGE" into your favourite search engine? Jeez...

  • Dwain Camps posted a great article on Performance of the SQL MERGE vs. INSERT/UPDATE[/url].

    "I cant stress enough the importance of switching from a sequential files mindset to set-based thinking. After you make the switch, you can spend your time tuning and optimizing your queries instead of maintaining lengthy, poor-performing code."

    -- Itzik Ben-Gan 2001

  • Lempster (12/10/2013)


    Can you not even be bothered to type "TSQL MERGE" into your favourite search engine? Jeez...

    Which, or how many, of the 297000 returns that Google brings back would you suggest the OP read??

    Best,
    Kevin G. Boles
    SQL Server Consultant
    SQL MVP 2007-2012
    TheSQLGuru on googles mail service

  • Which, or how many, of the 297000 returns that Google brings back would you suggest the OP read??

    How about number 1709? ;-). The point I am making Kevin, as you well know, is that there is an expectation that posters at least try to do some basic research before posting.

  • Alan.B (12/10/2013)


    Dwain Camps posted a great article on Performance of the SQL MERGE vs. INSERT/UPDATE[/url].

    If you read that, you should also look at the discussion thread where I ran some additional use cases using more memory, that sort of leveled the playing field.

    http://www.sqlservercentral.com/Forums/Topic1508736-3122-1.aspx

    This article may also be worth a look: A Hazard of Using the SQL Merge Statement [/url]


    My mantra: No loops! No CURSORs! No RBAR! Hoo-uh![/I]

    My thought question: Have you ever been told that your query runs too fast?

    My advice:
    INDEXing a poor-performing query is like putting sugar on cat food. Yeah, it probably tastes better but are you sure you want to eat it?
    The path of least resistance can be a slippery slope. Take care that fixing your fixes of fixes doesn't snowball and end up costing you more than fixing the root cause would have in the first place.

    Need to UNPIVOT? Why not CROSS APPLY VALUES instead?[/url]
    Since random numbers are too important to be left to chance, let's generate some![/url]
    Learn to understand recursive CTEs by example.[/url]
    [url url=http://www.sqlservercentral.com/articles/St

Viewing 7 posts - 1 through 6 (of 6 total)

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