Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR SQL

t-sql merge example


        
            
        
     MERGE sales.category t 
    USING sales.category_staging s
ON (s.category_id = t.category_id)
WHEN MATCHED
    THEN UPDATE SET 
        t.category_name = s.category_name,
        t.amount = s.amount
WHEN NOT MATCHED BY TARGET 
    THEN INSERT (category_id, category_name, amount)
         VALUES (s.category_id, s.category_name, s.amount)
WHEN NOT MATCHED BY SOURCE 
    THEN DELETE;
Source by www.sqlservertutorial.net #
 
PREVIOUS NEXT
Tagged: #merge
ADD COMMENT
Topic
Name
1+5 =