Search
 
SCRIPT & CODE EXAMPLE
 

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;
Comment

PREVIOUS NEXT
Code Example
Sql :: check constraint in sql 
Sql :: change auto increment mysql 
Sql :: select count 
Sql :: mysql cashing error 
Sql :: postgresql insert column 
Sql :: alter column to null 
Sql :: count column of tables psql 
Sql :: rename column sql 
Sql :: sql get last inserted row 
Sql :: 3 days back in sql server 
Sql :: run postgres docker 
Sql :: get record which is available in one table but not in another mysql 
Sql :: drop multiple columns in sql 
Sql :: mysql get last insert id 
Sql :: mysql dump specific tables 
Sql :: mysql ip address data type 
Sql :: check if sql is installed 
Sql :: sql select most frequent value in column 
Sql :: how to copy data in sql 
Sql :: update table disable constraint 
Sql :: postgres regular expression replace 
Sql :: sql insert from excel 
Sql :: incompatible sql_mode=only_full_group_by 
Sql :: postgresql get date now 
Sql :: python sqlite3 update 
Sql :: wherein sql 
Sql :: import sql in postgresql 
Sql :: mysql get nth highest 
Sql :: SQL Server Altering Column to be Unique 
Sql :: sql server create constraint 
ADD CONTENT
Topic
Content
Source link
Name
5+1 =