﻿<?xml version='1.0' encoding='UTF-8'?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/"><channel><title>SQLServerCentral / Article Discussions / Article Discussions by Author / Discuss content posted by Tommy Bollhofer  / SQL 2008 MERGE using Dynamic SQL over a Linked Server / Latest Posts</title><generator>InstantForum.NET v2.9.0</generator><description>SQLServerCentral</description><link>http://www.sqlservercentral.com/Forums/</link><webMaster>notifications@sqlservercentral.com</webMaster><lastBuildDate>Fri, 24 May 2013 04:27:24 GMT</lastBuildDate><ttl>20</ttl><item><title>RE: SQL 2008 MERGE using Dynamic SQL over a Linked Server</title><link>http://www.sqlservercentral.com/Forums/Topic692289-882-1.aspx</link><description>Very good point Helmut, thank you!</description><pubDate>Wed, 16 Mar 2011 10:37:32 GMT</pubDate><dc:creator>Tommy Bollhofer</dc:creator></item><item><title>RE: SQL 2008 MERGE using Dynamic SQL over a Linked Server</title><link>http://www.sqlservercentral.com/Forums/Topic692289-882-1.aspx</link><description>Thanks Tommy for this great procedure.But there's a problem if you want to merge a table with more than 2 columns in the PK. If you change[code="sql"]SELECT @pk_2 = 'AND ' + @local_schema_name + '_TARGET.' + column_name + ' = ' + @local_schema_name + '_SOURCE.' + column_name FROM @pk_table WHERE key_seq = 2[/code]into [code="sql"]SET @pk_2 = '';SELECT @pk_2 = @pk_2 + ' AND ' + @local_schema_name + '_TARGET.' + column_name + ' = ' + @local_schema_name + '_SOURCE.' + column_name  FROM @pk_table WHERE key_seq &amp;gt; 1;[/code]you can also handle tables with more than 2 columns as a PK.Best regardsHelmut</description><pubDate>Wed, 16 Mar 2011 09:30:31 GMT</pubDate><dc:creator>Helmut Rothtauscher</dc:creator></item><item><title>SQL 2008 MERGE using Dynamic SQL over a Linked Server</title><link>http://www.sqlservercentral.com/Forums/Topic692289-882-1.aspx</link><description>Comments posted to this topic are about the item [B]&lt;A HREF="/scripts/SQL+2008/66507/"&gt;SQL 2008 MERGE using Dynamic SQL over a Linked Server&lt;/A&gt;[/B]</description><pubDate>Tue, 07 Apr 2009 10:45:09 GMT</pubDate><dc:creator>Tommy Bollhofer</dc:creator></item></channel></rss>