Gabungkan kueri menggunakan server tertaut

--cannot use MERGE with Linked Server, so DELETE then INSERT
--example:
;WITH Source AS 
(
	Select col1, col2, col3
    FROM MySourceTable
)
--delete any matching rows from target
DELETE T
FROM LinkedServerName.DBName.dbo.MyTargetTable T
JOIN Source S ON
	S.col1 = T.col1  --join criteria

--now insert source rows
;WITH Source AS 
(
	Select col1, col2, col3
    FROM MySourceTable
)
INSERT INTO LinkedServerName.DBName.dbo.MyTargetTable
	(col1, col2, col3)
SELECT S.col1, s.col2, s.col3
FROM Source S
Ugly Unicorn