Merge (SQL) - Usage

Usage

MERGE INTO TABLE_NAME USING table_reference ON (condition) WHEN MATCHED THEN UPDATE SET column1 = value1 WHEN NOT MATCHED THEN INSERT (column1 ) VALUES (value1 [, value2 ...

Right join is employed over the Target (the INTO table) and the Source (the USING table / view / sub-query). That is:

  • rows present in the Source but missing from the Target do run the action > specifically the NOT MATCHED action
  • rows missing from the Source and present in Target are ignored > no action is performed on the Target.

If multiple Source rows match a given Target row, an error is mandated by SQL:2003 standards. You cannot update a Target row multiple times with a MERGE statement

Read more about this topic:  Merge (SQL)

Famous quotes containing the word usage:

    Girls who put out are tramps. Girls who don’t are ladies. This is, however, a rather archaic usage of the word. Should one of you boys happen upon a girl who doesn’t put out, do not jump to the conclusion that you have found a lady. What you have probably found is a lesbian.
    Fran Lebowitz (b. 1951)

    Pythagoras, Locke, Socrates—but pages
    Might be filled up, as vainly as before,
    With the sad usage of all sorts of sages,
    Who in his life-time, each was deemed a bore!
    The loftiest minds outrun their tardy ages.
    George Gordon Noel Byron (1788–1824)

    ...Often the accurate answer to a usage question begins, “It depends.” And what it depends on most often is where you are, who you are, who your listeners or readers are, and what your purpose in speaking or writing is.
    Kenneth G. Wilson (b. 1923)