Josh Harp
  • Posts: 11
  • Joined: 10/2/2017
MERGE <targettable, sysname, table>  AS TARGET
USING <sourcetable, sysname, table> AS SOURCE
ON (
 TARGET.<targetjoin, sysname, column> = SOURCE.<sourcejoin, sysname, column>
)
--WHEN MATCHED THEN (OPTIONAL 'AND' STATEMENT BEFORE 'THEN' TO PROVIDE ACTION CRITERIA)

---------------------------------------------------------
--MATCHED ACTION GOES HERE
---------------------------------------------------------

--WHEN NOT MATCHED BY TARGET THEN (OPTIONAL 'AND' STATEMENT BEFORE 'THEN' TO PROVIDE ACTION CRITERIA)

---------------------------------------------------------
--MATCHED ACTION GOES HERE
---------------------------------------------------------

--WHEN NOT MATCHED BY SOURCE THEN (OPTIONAL 'AND' STATEMENT BEFORE 'THEN' TO PROVIDE ACTION CRITERIA)

---------------------------------------------------------
--MATCHED ACTION GOES HERE
---------------------------------------------------------

-- OUTUPUT SECTION
--$action specifies a column of type nvarchar(10) 
--in the OUTPUT clause that returns one of three 
--values for each row: 'INSERT', 'UPDATE', or 'DELETE', 
--according to the action that was performed on that row
OUTPUT $action
--,inserted.-- COLUMN OF CHANGED DATA
--inserted.-- COLUMN OF CHANGED DATA
  • You cannot post new topics in this forum.
  • You cannot reply to topics in this forum.
  • You cannot delete your posts in this forum.
  • You cannot edit your posts in this forum.
  • You cannot create polls in this forum.
  • You cannot vote in polls in this forum.