Analyzing the SQL Server database is updated data exists, the data is not present the inserted

MERGE INTO方法:
MERGE INTO Sys_Dictionary the USING T1 (
 the SELECT  ' IntervalTime1 ' DictName, ' 1 0 0 1 *? * ' DictValue, ' external library interface ' DictType, ' first second execution 1st of the month ' Remarks
 of Union  the SELECT  ' IntervalTime2 ' , ' 2 0 2 * *? * ' , ' external library interface ' , ' 2:00 every day to perform two seconds '  
of Union  the SELECT  ' IntervalTime3 ' , ' 3 0 2 * *? * ',' External library interface ' , ' day 2:03 seconds perform '  
Union  SELECT  ' IntervalTime4 ' , ' . 4 0/5 * * *? * ' , ' External library interface ' , ' every 5-minute intervals of four seconds execution '  
) T2 the ON (t1.DictName = t2.DictName)
 the WHEN MATCHED THEN  the UPDATE  the SET t1.DictValue = t2.DictValue, t1.DictType = t2.DictType, t1.Remarks = t2.Remarks
 the WHEN  the NOT MATCHED THEN  the INSERT (DictName,DictValue,DictType,Remarks) VALUES (t2.DictName,t2.DictValue,t2.DictType,t2.Remarks);

 

Guess you like

Origin www.cnblogs.com/leon1984/p/11303632.html