Hi,I need to transfer a few 100k rows from one linked server to another on a daily basis and I was wondering which would perform better; a MERGE or an INSERT INTO ... WHERE NOT EXISTS. There will be no updating, only inserting and unfortunately there is no test system and the linked server is too bogged down to do any live testing. Is there any difference at all...? Here's my pseudo syntax ->MERGE localtable AS TargetUSING (SELECT Col1, Col2 FROM myLinkedServer.dbname.dbo.remotetable WHERE Transferred IS NULL) AS Source (Col1, Col2) ON ...WHEN NOT MATCHED THEN INSERT (Col1, Col2) ... INSERT INTO localtable (Col1, Col2)SELECT Col1, Col2FROM myLinkedServer.dbname.dbo.remotetable aWHERE NOT EXISTS ( SELECT 1 FROM localtable b WHERE a.Col1 = b.Col1 AND a.Col2 = b.Col2)
- LumbagoMy blog-> http://thefirstsql.com/2011/02/07/regular-expressions-advanced-string-matching-and-new-split-function-sql-server-2008-r2/