Merge Query for two database in SQL Server


merge TargetDatabase.dbo.TableName as target


using(select * from SourceDataBase.dbo.SourceTable) as source on target.C1= source.C1


when NOT MATCHED BY SOURCE  then DELETE


when not matched then 


insert(C1)values(source.C1)


when MATCHED then


update set target.C1=source.C1;

Comments

Popular posts from this blog

IRM and the Object Model

This content database has a schema version which is not supported in this farm

Activate and Deactivate Feature through PowerShell