<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" media="screen" href="/~d/styles/rss2full.xsl"?><?xml-stylesheet type="text/css" media="screen" href="http://feeds.feedburner.com/~d/styles/itemcontent.css"?><rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:sy="http://purl.org/rss/1.0/modules/syndication/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:feedburner="http://rssnamespace.org/feedburner/ext/1.0" version="2.0">

<channel>
	<title>SQLREPL | Brandon Williams</title>
	
	<link>http://www.sqlrepl.com</link>
	<description>Database professional on planning, deploying, and troubleshooting SQL Server Replication.</description>
	<lastBuildDate>Sat, 23 Mar 2013 21:04:23 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.5.1</generator>
<meta xmlns="http://www.w3.org/1999/xhtml" name="robots" content="noindex,follow" />
		<atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="self" type="application/rss+xml" href="http://feeds.feedburner.com/sqlrepl" /><feedburner:info uri="sqlrepl" /><atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="hub" href="http://pubsubhubbub.appspot.com/" /><image><link>http://www.sqlrepl.com</link><url>http://www.sqlrepl.com/wp-content/uploads/2011/12/SQLREPL_BLOG2.png</url><title>SQLREPL BLOG</title></image><item>
		<title>Central Subscriber Model Explained</title>
		<link>http://feedproxy.google.com/~r/sqlrepl/~3/C-6EeWTzH68/</link>
		<comments>http://www.sqlrepl.com/sql-server/central-subscriber-model-explained/#comments</comments>
		<pubDate>Mon, 28 Jan 2013 03:49:48 +0000</pubDate>
		<dc:creator>Brandon Williams</dc:creator>
				<category><![CDATA[Noteworthy]]></category>
		<category><![CDATA[Replication]]></category>
		<category><![CDATA[Snapshot]]></category>
		<category><![CDATA[SQL Server]]></category>
		<category><![CDATA[SQLServerPedia Syndication]]></category>
		<category><![CDATA[Transactional]]></category>
		<category><![CDATA[administration]]></category>
		<category><![CDATA[design]]></category>
		<category><![CDATA[implement]]></category>

		<guid isPermaLink="false">http://www.sqlrepl.com/?p=2852</guid>
		<description><![CDATA[The majority of SQL Server Replication topologies are based on the Central Publisher model, which is comprised of a single publisher replicating to one or more subscribers.  Another replication model, which is sometimes overlooked, is the Central Subscriber model, which is comprised of multiple publishers replicating to one subscriber using Transactional Replication. The Central Subscriber [...]]]></description>
				<content:encoded><![CDATA[<p>The majority of SQL Server Replication topologies are based on the Central Publisher model, which is comprised of a single publisher replicating to one or more subscribers.  Another replication model, which is sometimes overlooked, is the Central Subscriber model, which is comprised of multiple publishers replicating to one subscriber using Transactional Replication.</p>
<p><a href="http://www.sqlrepl.com/wp-content/uploads/2013/01/CentralSubscriberModel.png"><img class="alignnone size-full wp-image-2928" alt="Central Subscriber Model" src="http://www.sqlrepl.com/wp-content/uploads/2013/01/CentralSubscriberModel.png" width="287" height="387" /></a></p>
<p>The Central Subscriber model is useful for rolling up or consolidating data from multiple sources.  Some examples include:</p>
<ul>
<li>Rolling up inventory from several warehouses into a central server at corporate headquarters.</li>
</ul>
<ul>
<li>Sending data from remote offices within a company to a central office for business continuity.</li>
</ul>
<ul>
<li>Consolidating order information to one location for centralized ordering.</li>
</ul>
<h2>Priming the pump</h2>
<p>By default, subscriptions are initialized from a snapshot generated by the Snapshot Agent and then applied by the Distribution Agent.  When the snapshot is applied, by default the article property <i>Action if name is in use</i> is set to <b>Drop existing object and create a new one</b>, which instructs that the destination table be dropped if it already exists at a subscriber.  This behavior can be problematic in the Central Subscriber model when snapshots are applied since snapshots must be applied from multiple publications.  The first snapshot is applied as expected, however, subsequent snapshot applications result in the previous snapshot data being wiped out.</p>
<p>The solution to this problem is horizontal partitioning, static row filters, and setting the <em>Action if name is in use</em> article property to <strong>Delete data. If article has a row filter, delete only data that matches the filter</strong>.</p>
<h2>Horizontal partitioning</h2>
<p>Ideally, published tables in a Central Subscriber topology will be horizontally partitioned.  In order to horizontally partition the tables to be published, a location-specific column should be added and included as a part of a composite primary key.  Consider a table that looks like this:</p>

<div class="wp_syntax"><table><tr><td class="code"><pre class="tsql" style="font-family:monospace;"><span style="color: #0000FF;">CREATE</span> <span style="color: #0000FF;">TABLE</span> TestTable
<span style="color: #808080;">&#40;</span>
    ID <span style="color: #0000FF;">int</span> <span style="color: #0000FF;">IDENTITY</span><span style="color: #808080;">&#40;</span><span style="color: #000;">1</span>,<span style="color: #000;">1</span><span style="color: #808080;">&#41;</span> <span style="color: #808080;">NOT</span> <span style="color: #808080;">NULL</span>,
    FirstName <span style="color: #0000FF;">varchar</span><span style="color: #808080;">&#40;</span><span style="color: #000;">100</span><span style="color: #808080;">&#41;</span> <span style="color: #808080;">NULL</span>,
    <span style="color: #0000FF;">CONSTRAINT</span> PK_TestTable_ID <span style="color: #0000FF;">PRIMARY</span> <span style="color: #0000FF;">KEY</span> <span style="color: #0000FF;">CLUSTERED</span> <span style="color: #808080;">&#40;</span>ID <span style="color: #0000FF;">ASC</span><span style="color: #808080;">&#41;</span>
<span style="color: #808080;">&#41;</span></pre></td></tr></table></div>

<p>To horizontally partition <em>TestTable</em> and prepare it for a Central Subscriber configuration at Publisher 1, drop primary key constraint <em>PK_TestTable_ID</em>, add a location-specific column named <em>LocationID</em> with a default value of 1, and add the new composite primary key including the <em>LocationID</em> column.</p>

<div class="wp_syntax"><table><tr><td class="code"><pre class="tsql" style="font-family:monospace;"><span style="color: #0000FF;">ALTER</span> <span style="color: #0000FF;">TABLE</span> TestTable
<span style="color: #0000FF;">DROP</span> <span style="color: #0000FF;">CONSTRAINT</span> PK_TestTable_ID
GO
&nbsp;
<span style="color: #0000FF;">ALTER</span> <span style="color: #0000FF;">TABLE</span> TestTable
<span style="color: #0000FF;">ADD</span> LocationID <span style="color: #0000FF;">INT</span> <span style="color: #808080;">NOT</span> <span style="color: #808080;">NULL</span> <span style="color: #0000FF;">DEFAULT</span><span style="color: #808080;">&#40;</span><span style="color: #000;">1</span><span style="color: #808080;">&#41;</span>
GO
&nbsp;
<span style="color: #0000FF;">ALTER</span> <span style="color: #0000FF;">TABLE</span> TestTable
<span style="color: #0000FF;">ADD</span> <span style="color: #0000FF;">CONSTRAINT</span> PK_TestTable_ID_LocationID <span style="color: #0000FF;">PRIMARY</span> <span style="color: #0000FF;">KEY</span> <span style="color: #0000FF;">CLUSTERED</span> <span style="color: #808080;">&#40;</span>ID, LocationID<span style="color: #808080;">&#41;</span>
GO</pre></td></tr></table></div>

<p>Next, to horizontally partition <em>TestTable</em> and prepare it for a Central Subscriber configuration at Publisher 2, the same preparation can be done with a default value of 2 for <em>LocationID</em>.</p>

<div class="wp_syntax"><table><tr><td class="code"><pre class="tsql" style="font-family:monospace;"><span style="color: #0000FF;">ALTER</span> <span style="color: #0000FF;">TABLE</span> TestTable
<span style="color: #0000FF;">DROP</span> <span style="color: #0000FF;">CONSTRAINT</span> PK_TestTable_ID
GO
&nbsp;
<span style="color: #0000FF;">ALTER</span> <span style="color: #0000FF;">TABLE</span> TestTable
<span style="color: #0000FF;">ADD</span> LocationID <span style="color: #0000FF;">INT</span> <span style="color: #808080;">NOT</span> <span style="color: #808080;">NULL</span> <span style="color: #0000FF;">DEFAULT</span><span style="color: #808080;">&#40;</span><span style="color: #000;">2</span><span style="color: #808080;">&#41;</span>
GO
&nbsp;
<span style="color: #0000FF;">ALTER</span> <span style="color: #0000FF;">TABLE</span> TestTable
<span style="color: #0000FF;">ADD</span> <span style="color: #0000FF;">CONSTRAINT</span> PK_TestTable_ID_LocationID <span style="color: #0000FF;">PRIMARY</span> <span style="color: #0000FF;">KEY</span> <span style="color: #0000FF;">CLUSTERED</span> <span style="color: #808080;">&#40;</span>ID, LocationID<span style="color: #808080;">&#41;</span>
GO</pre></td></tr></table></div>

<p>Finally, to horizontally partition <em>TestTable</em> and prepare it for a Central Subscriber configuration at Publisher 3, the same preparation can be done with a default value of 3 for <em>LocationID</em>.</p>

<div class="wp_syntax"><table><tr><td class="code"><pre class="tsql" style="font-family:monospace;"><span style="color: #0000FF;">ALTER</span> <span style="color: #0000FF;">TABLE</span> TestTable
<span style="color: #0000FF;">DROP</span> <span style="color: #0000FF;">CONSTRAINT</span> PK_TestTable_ID
GO
&nbsp;
<span style="color: #0000FF;">ALTER</span> <span style="color: #0000FF;">TABLE</span> TestTable
<span style="color: #0000FF;">ADD</span> LocationID <span style="color: #0000FF;">INT</span> <span style="color: #808080;">NOT</span> <span style="color: #808080;">NULL</span> <span style="color: #0000FF;">DEFAULT</span><span style="color: #808080;">&#40;</span><span style="color: #000;">3</span><span style="color: #808080;">&#41;</span>
GO
&nbsp;
<span style="color: #0000FF;">ALTER</span> <span style="color: #0000FF;">TABLE</span> TestTable
<span style="color: #0000FF;">ADD</span> <span style="color: #0000FF;">CONSTRAINT</span> PK_TestTable_ID_LocationID <span style="color: #0000FF;">PRIMARY</span> <span style="color: #0000FF;">KEY</span> <span style="color: #0000FF;">CLUSTERED</span> <span style="color: #808080;">&#40;</span>ID, LocationID<span style="color: #808080;">&#41;</span>
GO</pre></td></tr></table></div>

<p>Once the tables are horizontally partitioned, they can be properly published in a Central Subscriber topology by using static row filters, filtering on the <em>LocationID</em> column and setting the article property <em>Action if name is in use</em> to <strong>Delete data. If article has a row filter, delete only data that matches the filter</strong>.</p>
<h2>Static row filters</h2>
<p>For each article to be published in a Central Subscriber topology, a static row filter should be defined to leverage the <em>Action if name is in use</em> article property appropriately.  A static row filter uses a WHERE clause to select the data to be published.  To publish rows from Publisher 1, specify <em>LocationID = 1</em> for the filter clause. Likewise, to publish rows from Publisher 2 and Publisher 3, specify <em>LocationID = 2</em> and <em>LocationID = 3</em> for the filter clause, respectively.</p>
<p><a href="http://www.sqlrepl.com/wp-content/uploads/2013/01/StaticRowFilters.png"><img class="alignleft size-full wp-image-2938" style="box-shadow: 0px 7px 7px #888888; margin-bottom: 20px;" alt="Static Row Filters" src="http://www.sqlrepl.com/wp-content/uploads/2013/01/StaticRowFilters.png" width="599" height="404" /></a></p>
<h2>Action if name is in use</h2>
<p>When creating the publications and adding articles, the article property <em>Action if name is in use</em> needs to be set to <strong>Delete data. If article has a row filter, delete only data that matches the filter</strong>.  This can be set using the <em>New Publication Wizard Article Properties</em> dialog or by using replication stored procedures <a title="sp_addarticle" href="http://msdn.microsoft.com/en-us/library/ms173857.aspx" target="_blank" rel="nofollow">sp_addarticle</a> and specifying a value of <strong>delete</strong> for the <em>@pre_creation_cmd</em> argument.  This way, when the central subscriber is initialized or reinitialized from multiple publication snapshots, previously applied snapshot data will be preserved since only data matching the filter clause will be deleted.</p>
<p><a href="http://www.sqlrepl.com/wp-content/uploads/2013/01/ActionIfNameIsInUseProperty.png"><img class="alignleft size-full wp-image-2921" style="box-shadow: 0px 7px 7px #888888; margin-bottom: 20px;" alt="Action if name is in use" src="http://www.sqlrepl.com/wp-content/uploads/2013/01/ActionIfNameIsInUseProperty.png" width="591" height="97" /></a></p>
<h2>The caveat</h2>
<p>As we can see, horizontal partitioning requires that tables have a location-specific column added, however, the location-specific column does not necessarily need to be included as a part of the primary key at the publication databases.  In addition, it is not a hard requirement that published tables in a Central Subscriber topology be horizontally partitioned.  In some shops, changing a primary key or adding additional columns is strictly prohibited, in which case I would urge you to take an alternative approach.  If you would like some ideas on implementing a Central Subscriber topology without modifying primary keys or horizontally partitioning publication databases, feel free to <a title="get in touch" href="http://www.sqlrepl.com/contact/" target="_blank">get in touch</a> or leave a comment below.</p>
<p>-Brandon Williams (<a title="SQLREPL | Brandon Williams" href="http://www.sqlrepl.com" target="_blank">blog</a> | <a title="Connect on LinkedIn" href="http://www.linkedin.com/in/isbrandon" target="_blank">linkedin</a> | <a title="Follow me on Twitter" href="https://twitter.com/is_brandon" target="_blank">twitter</a>)</p>
<div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/sqlrepl?a=C-6EeWTzH68:pph3slbw8cg:3QFJfmc7Om4"><img src="http://feeds.feedburner.com/~ff/sqlrepl?i=C-6EeWTzH68:pph3slbw8cg:3QFJfmc7Om4" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/sqlrepl?a=C-6EeWTzH68:pph3slbw8cg:dnMXMwOfBR0"><img src="http://feeds.feedburner.com/~ff/sqlrepl?d=dnMXMwOfBR0" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/sqlrepl?a=C-6EeWTzH68:pph3slbw8cg:F7zBnMyn0Lo"><img src="http://feeds.feedburner.com/~ff/sqlrepl?i=C-6EeWTzH68:pph3slbw8cg:F7zBnMyn0Lo" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/sqlrepl?a=C-6EeWTzH68:pph3slbw8cg:V_sGLiPBpWU"><img src="http://feeds.feedburner.com/~ff/sqlrepl?i=C-6EeWTzH68:pph3slbw8cg:V_sGLiPBpWU" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/sqlrepl?a=C-6EeWTzH68:pph3slbw8cg:gIN9vFwOqvQ"><img src="http://feeds.feedburner.com/~ff/sqlrepl?i=C-6EeWTzH68:pph3slbw8cg:gIN9vFwOqvQ" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/sqlrepl?a=C-6EeWTzH68:pph3slbw8cg:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/sqlrepl?d=yIl2AUoC8zA" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/sqlrepl/~4/C-6EeWTzH68" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.sqlrepl.com/sql-server/central-subscriber-model-explained/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://www.sqlrepl.com/sql-server/central-subscriber-model-explained/</feedburner:origLink></item>
		<item>
		<title>Chad Churchwell: Protect Your Replication Environment with AlwaysOn Availability Groups</title>
		<link>http://feedproxy.google.com/~r/sqlrepl/~3/ReswREZymK4/</link>
		<comments>http://www.sqlrepl.com/sql-server/chad-churchwell-protect-your-replication-environment-with-alwayson-availability-groups/#comments</comments>
		<pubDate>Wed, 16 Jan 2013 02:55:33 +0000</pubDate>
		<dc:creator>Brandon Williams</dc:creator>
				<category><![CDATA[Replication]]></category>
		<category><![CDATA[SQL Server]]></category>
		<category><![CDATA[SQLServerPedia Syndication]]></category>
		<category><![CDATA[administration]]></category>

		<guid isPermaLink="false">http://www.sqlrepl.com/?p=2801</guid>
		<description><![CDATA[Heads up everyone.  Next Tuesday January 22nd, 2013 Chad Churchwell (blog &#124; twitter) will be presenting a webinar on behalf of Pragmatic Works on protecting your replication environment with AlwaysOn Availability Groups.  I've had the pleasure of following Chad over the last year and have really come to appreciate his dedication and commitment to providing [...]]]></description>
				<content:encoded><![CDATA[<p>Heads up everyone.  Next Tuesday January 22nd, 2013 Chad Churchwell (<a title="SQLCHAD - Life as a SQL Server DBA" href="http://sqlchad.com/" target="_blank">blog</a> | <a title="@chadchurchwell" href="https://twitter.com/chadchurchwell" target="_blank">twitter</a>) will be presenting a webinar on behalf of Pragmatic Works on protecting your replication environment with AlwaysOn Availability Groups.  I've had the pleasure of following Chad over the last year and have really come to appreciate his dedication and commitment to providing quality replication content to the SQL Server Community.  According to his author profile at <a title="MSSQLTips Author Profile - Chad Churchwell" href="http://www.mssqltips.com/sqlserverauthor/90/chad-churchwell/" target="_blank">MSSQLTips</a>:</p>
<blockquote><p>Chad Churchwell is a SQL Server professional specializing in High Availability, Disaster Recovery, and Replication. He has been in IT for 14 years, working with SQL Server for 10 years, and is currently a senior DBA Consultant with Pragmatic Works. He is active in the community speaking at several SQL Saturday events, as well as maintaining a blog at www.sqlchad.com.</p></blockquote>
<p>With the release of SQL Server 2012, replication received support for AlwaysOn Availability Groups.  Come listen to Chad Churchwell discuss the supported scenarios and how to achieve high availability for your replication topologies.  We should be in for a treat and I hope to see you all there.</p>
<p><a href="http://pragmaticworks.com/LearningCenter/FreeTrainingWebinars/WebinarDetails.aspx?ResourceId=494" target="_blank"><img class="alignleft size-full wp-image-2814" style="box-shadow: 0px 7px 7px #888888;" alt="Protect Your Replication Environment with AlwaysOn Availability Groups" src="http://www.sqlrepl.com/wp-content/uploads/2013/01/ProtectYourReplicationEnvironmentWithAlwaysOnAvailabilityGroups.png" width="958" height="195" /></a><br />
&nbsp;<br />
<strong>Registration</strong>: <a title="Protect Your Replication Enviroment with AlwaysOn Availability Groups - Pragmatic Works Webinars" href="http://pragmaticworks.com/LearningCenter/FreeTrainingWebinars/WebinarDetails.aspx?ResourceId=494" target="_blank">Protect Your Replication Environment with AlwaysOn Availability Groups</a></p>
<p><strong>Date and time</strong>:  January 22nd 2013 11:00 am Eastern</p>
<p><strong>Abstract</strong>:</p>
<blockquote><p>This session is intended to show how you can combine AlwaysOn Availability Groups to protect your replication environment for High Availability. We will cover supported scenarios for replication, publisher and subscriber setup, and different failure points in your replication topology. We will conclude with a demo on failover of a publisher and subscriber.</p></blockquote>
<p>-Brandon Williams (<a title="SQLREPL | Brandon Williams" href="http://www.sqlrepl.com" target="_blank">blog</a> | <a title="Connect on LinkedIn" href="http://www.linkedin.com/in/isbrandon" target="_blank">linkedin</a> | <a title="Follow me on Twitter" href="https://twitter.com/is_brandon" target="_blank">twitter</a>)</p>
<div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/sqlrepl?a=ReswREZymK4:bG_TZkRFKRg:3QFJfmc7Om4"><img src="http://feeds.feedburner.com/~ff/sqlrepl?i=ReswREZymK4:bG_TZkRFKRg:3QFJfmc7Om4" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/sqlrepl?a=ReswREZymK4:bG_TZkRFKRg:dnMXMwOfBR0"><img src="http://feeds.feedburner.com/~ff/sqlrepl?d=dnMXMwOfBR0" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/sqlrepl?a=ReswREZymK4:bG_TZkRFKRg:F7zBnMyn0Lo"><img src="http://feeds.feedburner.com/~ff/sqlrepl?i=ReswREZymK4:bG_TZkRFKRg:F7zBnMyn0Lo" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/sqlrepl?a=ReswREZymK4:bG_TZkRFKRg:V_sGLiPBpWU"><img src="http://feeds.feedburner.com/~ff/sqlrepl?i=ReswREZymK4:bG_TZkRFKRg:V_sGLiPBpWU" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/sqlrepl?a=ReswREZymK4:bG_TZkRFKRg:gIN9vFwOqvQ"><img src="http://feeds.feedburner.com/~ff/sqlrepl?i=ReswREZymK4:bG_TZkRFKRg:gIN9vFwOqvQ" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/sqlrepl?a=ReswREZymK4:bG_TZkRFKRg:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/sqlrepl?d=yIl2AUoC8zA" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/sqlrepl/~4/ReswREZymK4" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.sqlrepl.com/sql-server/chad-churchwell-protect-your-replication-environment-with-alwayson-availability-groups/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://www.sqlrepl.com/sql-server/chad-churchwell-protect-your-replication-environment-with-alwayson-availability-groups/</feedburner:origLink></item>
		<item>
		<title>Auditing changes in Merge Replication</title>
		<link>http://feedproxy.google.com/~r/sqlrepl/~3/rqVJbfgp3eE/</link>
		<comments>http://www.sqlrepl.com/sql-server/auditing-changes-in-merge-replication/#comments</comments>
		<pubDate>Wed, 10 Oct 2012 12:55:15 +0000</pubDate>
		<dc:creator>Brandon Williams</dc:creator>
				<category><![CDATA[Merge]]></category>
		<category><![CDATA[Noteworthy]]></category>
		<category><![CDATA[Replication]]></category>
		<category><![CDATA[SQL Server]]></category>
		<category><![CDATA[SQLServerPedia Syndication]]></category>
		<category><![CDATA[Troubleshoot]]></category>
		<category><![CDATA[administration]]></category>
		<category><![CDATA[audit]]></category>
		<category><![CDATA[conflicts]]></category>
		<category><![CDATA[develop]]></category>
		<category><![CDATA[troubleshoot]]></category>

		<guid isPermaLink="false">http://www.sqlrepl.com/?p=2562</guid>
		<description><![CDATA[One trick I have learned from the folks on the Replication Support Team is how to proactively audit data changes in Merge Replication.  This is useful when troubleshooting issues such as identifying where data changes are coming from, who is causing them, and what the data is before and after the change.  I have found [...]]]></description>
				<content:encoded><![CDATA[<p>One trick I have learned from the folks on the Replication Support Team is how to proactively audit data changes in Merge Replication.  This is useful when troubleshooting issues such as identifying where data changes are coming from, who is causing them, and what the data is before and after the change.  I have found this valuable information to have on a few occasions and thought I would share.</p>
<p><em><strong>Keep in mind this should only be used for troubleshooting purposes and should always be tested in pre-production prior to deploying.  Make sure it works first!</strong></em></p>
<p>Auditing data changes for a Merge article can be done by creating insert, update, and delete triggers to capture data changes and record them into an audit table.  The audit table rows consist of <a title="GETDATE()" href="http://msdn.microsoft.com/en-us/library/ms188383.aspx" rel="nofollow" target="_blank">GETDATE()</a>, <a title="APP_NAME()" href="http://msdn.microsoft.com/en-us/library/ms189770.aspx" rel="nofollow" target="_blank">APP_NAME()</a>, <a title="HOST_NAME()" href="http://msdn.microsoft.com/en-us/library/ms178598.aspx" rel="nofollow" target="_blank">HOST_NAME()</a>, <a title="SUSER_NAME()" href="http://msdn.microsoft.com/en-us/library/ms187934.aspx" rel="nofollow" target="_blank">SUSER_NAME()</a>, column data, action type, command, and spid for each insert, update, and delete that occurs on the article to audit.  You will have to modify the script to adjust the name of the table being audited and the relevant columns that you think should be included in the audit data.  Usually just the primary key columns are enough, but other columns can be included as well.</p>
<h2>Audit script</h2>

<div class="wp_syntax"><table><tr><td class="code"><pre class="tsql" style="font-family:monospace;"><span style="color: #008080;">/************************************************************************
This is a script to implement audit triggers of insert, update, delete on 
a base table. It is based on a generic scenario for a table with four 
columns col1, col2, col3, col4.
&nbsp;
It will insert into a table called source_audit.
&nbsp;
Run this script on the database you would like to audit.
&nbsp;
Test first to be sure it is working as expected!
&nbsp;
After the problem occurs, export the contents of the source_audit table.
************************************************************************/</span>
&nbsp;
<span style="color: #0000FF;">USE</span> DB_to_audit
GO
&nbsp;
<span style="color: #008080;">-- Drop audit table if exists</span>
<span style="color: #0000FF;">IF</span>  <span style="color: #808080;">EXISTS</span> <span style="color: #808080;">&#40;</span><span style="color: #0000FF;">SELECT</span> <span style="color: #808080;">*</span> <span style="color: #0000FF;">FROM</span> sys.<span style="color: #202020;">objects</span> <span style="color: #0000FF;">WHERE</span> <span style="color: #FF00FF;">object_id</span> <span style="color: #808080;">=</span> <span style="color: #FF00FF;">OBJECT_ID</span><span style="color: #808080;">&#40;</span>N<span style="color: #FF0000;">'[dbo].[source_audit]'</span><span style="color: #808080;">&#41;</span> <span style="color: #808080;">AND</span> type in <span style="color: #808080;">&#40;</span>N<span style="color: #FF0000;">'U'</span><span style="color: #808080;">&#41;</span><span style="color: #808080;">&#41;</span>
<span style="color: #0000FF;">DROP</span> <span style="color: #0000FF;">TABLE</span> <span style="color: #808080;">&#91;</span>dbo<span style="color: #808080;">&#93;</span>.<span style="color: #808080;">&#91;</span>source_audit<span style="color: #808080;">&#93;</span>
&nbsp;
<span style="color: #008080;">-- Create audit table</span>
<span style="color: #0000FF;">CREATE</span> <span style="color: #0000FF;">TABLE</span> <span style="color: #808080;">&#91;</span>dbo<span style="color: #808080;">&#93;</span>.<span style="color: #808080;">&#91;</span>source_audit<span style="color: #808080;">&#93;</span>
    <span style="color: #808080;">&#40;</span><span style="color: #808080;">&#91;</span>tstamp<span style="color: #808080;">&#93;</span> <span style="color: #0000FF;">datetime</span> <span style="color: #808080;">NULL</span>, 
     <span style="color: #808080;">&#91;</span>ProgramName<span style="color: #808080;">&#93;</span> <span style="color: #0000FF;">nvarchar</span><span style="color: #808080;">&#40;</span><span style="color: #000;">128</span><span style="color: #808080;">&#41;</span> <span style="color: #808080;">NULL</span>, 
     <span style="color: #808080;">&#91;</span>hostname<span style="color: #808080;">&#93;</span> <span style="color: #0000FF;">nvarchar</span><span style="color: #808080;">&#40;</span><span style="color: #000;">128</span><span style="color: #808080;">&#41;</span> <span style="color: #808080;">NULL</span>, 
     <span style="color: #808080;">&#91;</span>suser<span style="color: #808080;">&#93;</span> <span style="color: #0000FF;">nvarchar</span><span style="color: #808080;">&#40;</span><span style="color: #000;">128</span><span style="color: #808080;">&#41;</span> <span style="color: #808080;">NULL</span>,
     <span style="color: #808080;">&#91;</span>col1<span style="color: #808080;">&#93;</span> <span style="color: #0000FF;">int</span> ,
     <span style="color: #808080;">&#91;</span>col2<span style="color: #808080;">&#93;</span> <span style="color: #0000FF;">nchar</span><span style="color: #808080;">&#40;</span><span style="color: #000;">10</span><span style="color: #808080;">&#41;</span> <span style="color: #808080;">NULL</span>,
     <span style="color: #808080;">&#91;</span>col3<span style="color: #808080;">&#93;</span> <span style="color: #0000FF;">datetime</span> <span style="color: #808080;">NULL</span>,
     <span style="color: #808080;">&#91;</span>col4<span style="color: #808080;">&#93;</span> <span style="color: #0000FF;">binary</span> <span style="color: #808080;">NULL</span>,
     <span style="color: #808080;">&#91;</span>actiontype<span style="color: #808080;">&#93;</span> <span style="color: #0000FF;">char</span><span style="color: #808080;">&#40;</span><span style="color: #000;">2</span><span style="color: #808080;">&#41;</span> <span style="color: #808080;">NULL</span>,
     <span style="color: #808080;">&#91;</span>inputbuffer<span style="color: #808080;">&#93;</span> <span style="color: #0000FF;">nvarchar</span><span style="color: #808080;">&#40;</span><span style="color: #000;">255</span><span style="color: #808080;">&#41;</span> <span style="color: #808080;">NULL</span>,
     <span style="color: #808080;">&#91;</span>spid<span style="color: #808080;">&#93;</span> <span style="color: #0000FF;">int</span> <span style="color: #808080;">NULL</span><span style="color: #808080;">&#41;</span>
GO
&nbsp;
<span style="color: #008080;">-------------------------------------------</span>
<span style="color: #008080;">-- INSERT trigger</span>
<span style="color: #008080;">-------------------------------------------</span>
&nbsp;
<span style="color: #008080;">-- Delete trigger if exists</span>
<span style="color: #0000FF;">IF</span>  <span style="color: #808080;">EXISTS</span> <span style="color: #808080;">&#40;</span><span style="color: #0000FF;">SELECT</span> <span style="color: #808080;">*</span> <span style="color: #0000FF;">FROM</span> sys.<span style="color: #202020;">triggers</span> <span style="color: #0000FF;">WHERE</span> <span style="color: #FF00FF;">object_id</span> <span style="color: #808080;">=</span> <span style="color: #FF00FF;">OBJECT_ID</span><span style="color: #808080;">&#40;</span>N<span style="color: #FF0000;">'[dbo].[audit_source_INS]'</span><span style="color: #808080;">&#41;</span><span style="color: #808080;">&#41;</span>
<span style="color: #0000FF;">DROP</span> <span style="color: #0000FF;">TRIGGER</span> <span style="color: #808080;">&#91;</span>dbo<span style="color: #808080;">&#93;</span>.<span style="color: #808080;">&#91;</span>audit_source_<span style="color: #808080;">IN</span>S<span style="color: #808080;">&#93;</span>
GO
&nbsp;
<span style="color: #008080;">-- Create INSERT trigger</span>
<span style="color: #0000FF;">CREATE</span> <span style="color: #0000FF;">TRIGGER</span> audit_source_<span style="color: #808080;">IN</span>S
<span style="color: #0000FF;">on</span> Table_1
<span style="color: #0000FF;">FOR</span> <span style="color: #0000FF;">INSERT</span>
<span style="color: #0000FF;">AS</span>
<span style="color: #0000FF;">DECLARE</span> @command <span style="color: #0000FF;">NVARCHAR</span><span style="color: #808080;">&#40;</span><span style="color: #000;">255</span><span style="color: #808080;">&#41;</span>
&nbsp;
<span style="color: #0000FF;">if</span> <span style="color: #000;">0</span> <span style="color: #808080;">=</span> <span style="color: #808080;">&#40;</span><span style="color: #0000FF;">select</span> <span style="color: #FF00FF;">count</span><span style="color: #808080;">&#40;</span><span style="color: #808080;">*</span><span style="color: #808080;">&#41;</span> <span style="color: #0000FF;">from</span> inserted<span style="color: #808080;">&#41;</span> <span style="color: #0000FF;">return</span>
&nbsp;
<span style="color: #0000FF;">CREATE</span> <span style="color: #0000FF;">TABLE</span> #InputBuffer <span style="color: #808080;">&#40;</span><span style="color: #808080;">&#91;</span>eventtype<span style="color: #808080;">&#93;</span> <span style="color: #0000FF;">NVARCHAR</span><span style="color: #808080;">&#40;</span><span style="color: #000;">30</span><span style="color: #808080;">&#41;</span>, <span style="color: #808080;">&#91;</span><span style="color: #0000FF;">parameters</span><span style="color: #808080;">&#93;</span> <span style="color: #0000FF;">INT</span>, <span style="color: #808080;">&#91;</span>eventinfo<span style="color: #808080;">&#93;</span> <span style="color: #0000FF;">NVARCHAR</span><span style="color: #808080;">&#40;</span><span style="color: #000;">255</span><span style="color: #808080;">&#41;</span><span style="color: #808080;">&#41;</span>
<span style="color: #0000FF;">INSERT</span> <span style="color: #0000FF;">INTO</span> #InputBuffer <span style="color: #0000FF;">exec</span><span style="color: #808080;">&#40;</span><span style="color: #FF0000;">'DBCC INPUTBUFFER(@@spid) WITH NO_INFOMSGS'</span><span style="color: #808080;">&#41;</span>
<span style="color: #0000FF;">SELECT</span> @command<span style="color: #808080;">=</span>eventinfo <span style="color: #0000FF;">from</span> #InputBuffer
&nbsp;
<span style="color: #0000FF;">INSERT</span> <span style="color: #0000FF;">INTO</span> source_audit
<span style="color: #0000FF;">SELECT</span> <span style="color: #FF00FF;">getdate</span><span style="color: #808080;">&#40;</span><span style="color: #808080;">&#41;</span>, <span style="color: #FF00FF;">app_name</span><span style="color: #808080;">&#40;</span><span style="color: #808080;">&#41;</span>, <span style="color: #FF00FF;">host_name</span><span style="color: #808080;">&#40;</span><span style="color: #808080;">&#41;</span>, suser_name<span style="color: #808080;">&#40;</span><span style="color: #808080;">&#41;</span>, col1, col2, col3, col4, <span style="color: #FF0000;">'I'</span>, @command, <span style="color: #FF00FF;">@@SPID</span>
<span style="color: #0000FF;">FROM</span> inserted
GO
&nbsp;
<span style="color: #008080;">-------------------------------------------</span>
<span style="color: #008080;">-- UPDATE trigger</span>
<span style="color: #008080;">-------------------------------------------</span>
&nbsp;
<span style="color: #008080;">-- Delete trigger if exists</span>
<span style="color: #0000FF;">IF</span>  <span style="color: #808080;">EXISTS</span> <span style="color: #808080;">&#40;</span><span style="color: #0000FF;">SELECT</span> <span style="color: #808080;">*</span> <span style="color: #0000FF;">FROM</span> sys.<span style="color: #202020;">triggers</span> <span style="color: #0000FF;">WHERE</span> <span style="color: #FF00FF;">object_id</span> <span style="color: #808080;">=</span> <span style="color: #FF00FF;">OBJECT_ID</span><span style="color: #808080;">&#40;</span>N<span style="color: #FF0000;">'[dbo].[audit_source_UPD]'</span><span style="color: #808080;">&#41;</span><span style="color: #808080;">&#41;</span>
<span style="color: #0000FF;">DROP</span> <span style="color: #0000FF;">TRIGGER</span> <span style="color: #808080;">&#91;</span>dbo<span style="color: #808080;">&#93;</span>.<span style="color: #808080;">&#91;</span>audit_source_UPD<span style="color: #808080;">&#93;</span>
GO
&nbsp;
<span style="color: #008080;">-- Create UPDATE trigger</span>
<span style="color: #0000FF;">CREATE</span> <span style="color: #0000FF;">TRIGGER</span> audit_source_UPD
<span style="color: #0000FF;">on</span> Table_1
<span style="color: #0000FF;">FOR</span> <span style="color: #0000FF;">UPDATE</span>
<span style="color: #0000FF;">AS</span>
<span style="color: #0000FF;">DECLARE</span> @command <span style="color: #0000FF;">NVARCHAR</span><span style="color: #808080;">&#40;</span><span style="color: #000;">255</span><span style="color: #808080;">&#41;</span>
&nbsp;
<span style="color: #0000FF;">if</span> <span style="color: #000;">0</span> <span style="color: #808080;">=</span> <span style="color: #808080;">&#40;</span><span style="color: #0000FF;">select</span> <span style="color: #FF00FF;">count</span><span style="color: #808080;">&#40;</span><span style="color: #808080;">*</span><span style="color: #808080;">&#41;</span> <span style="color: #0000FF;">from</span> inserted<span style="color: #808080;">&#41;</span> <span style="color: #0000FF;">return</span>
&nbsp;
<span style="color: #0000FF;">CREATE</span> <span style="color: #0000FF;">TABLE</span> #InputBuffer <span style="color: #808080;">&#40;</span><span style="color: #808080;">&#91;</span>eventtype<span style="color: #808080;">&#93;</span> <span style="color: #0000FF;">NVARCHAR</span><span style="color: #808080;">&#40;</span><span style="color: #000;">30</span><span style="color: #808080;">&#41;</span>, <span style="color: #808080;">&#91;</span><span style="color: #0000FF;">parameters</span><span style="color: #808080;">&#93;</span> <span style="color: #0000FF;">INT</span>, <span style="color: #808080;">&#91;</span>eventinfo<span style="color: #808080;">&#93;</span> <span style="color: #0000FF;">NVARCHAR</span><span style="color: #808080;">&#40;</span><span style="color: #000;">255</span><span style="color: #808080;">&#41;</span><span style="color: #808080;">&#41;</span>
<span style="color: #0000FF;">INSERT</span> <span style="color: #0000FF;">INTO</span> #InputBuffer <span style="color: #0000FF;">exec</span><span style="color: #808080;">&#40;</span><span style="color: #FF0000;">'DBCC INPUTBUFFER(@@spid) WITH NO_INFOMSGS'</span><span style="color: #808080;">&#41;</span>
<span style="color: #0000FF;">SELECT</span> @command<span style="color: #808080;">=</span>eventinfo <span style="color: #0000FF;">from</span> #InputBuffer
&nbsp;
<span style="color: #0000FF;">INSERT</span> <span style="color: #0000FF;">INTO</span> source_audit
<span style="color: #0000FF;">SELECT</span> <span style="color: #FF00FF;">getdate</span><span style="color: #808080;">&#40;</span><span style="color: #808080;">&#41;</span>, <span style="color: #FF00FF;">app_name</span><span style="color: #808080;">&#40;</span><span style="color: #808080;">&#41;</span>, <span style="color: #FF00FF;">host_name</span><span style="color: #808080;">&#40;</span><span style="color: #808080;">&#41;</span>, suser_name<span style="color: #808080;">&#40;</span><span style="color: #808080;">&#41;</span>, col1, col2, col3, col4, <span style="color: #FF0000;">'UD'</span>, @command, <span style="color: #FF00FF;">@@SPID</span>
<span style="color: #0000FF;">FROM</span> deleted
<span style="color: #0000FF;">INSERT</span> <span style="color: #0000FF;">INTO</span> source_audit
<span style="color: #0000FF;">SELECT</span> <span style="color: #FF00FF;">getdate</span><span style="color: #808080;">&#40;</span><span style="color: #808080;">&#41;</span>, <span style="color: #FF00FF;">app_name</span><span style="color: #808080;">&#40;</span><span style="color: #808080;">&#41;</span>, <span style="color: #FF00FF;">host_name</span><span style="color: #808080;">&#40;</span><span style="color: #808080;">&#41;</span>, suser_name<span style="color: #808080;">&#40;</span><span style="color: #808080;">&#41;</span>, col1, col2, col3, col4, <span style="color: #FF0000;">'UI'</span>, @command, <span style="color: #FF00FF;">@@SPID</span>
<span style="color: #0000FF;">FROM</span> inserted
GO
&nbsp;
<span style="color: #008080;">-------------------------------------------</span>
<span style="color: #008080;">-- DELETE trigger</span>
<span style="color: #008080;">-------------------------------------------</span>
&nbsp;
<span style="color: #008080;">-- Delete trigger if exists</span>
<span style="color: #0000FF;">IF</span>  <span style="color: #808080;">EXISTS</span> <span style="color: #808080;">&#40;</span><span style="color: #0000FF;">SELECT</span> <span style="color: #808080;">*</span> <span style="color: #0000FF;">FROM</span> sys.<span style="color: #202020;">triggers</span> <span style="color: #0000FF;">WHERE</span> <span style="color: #FF00FF;">object_id</span> <span style="color: #808080;">=</span> <span style="color: #FF00FF;">OBJECT_ID</span><span style="color: #808080;">&#40;</span>N<span style="color: #FF0000;">'[dbo].[audit_source_DEL]'</span><span style="color: #808080;">&#41;</span><span style="color: #808080;">&#41;</span>
<span style="color: #0000FF;">DROP</span> <span style="color: #0000FF;">TRIGGER</span> <span style="color: #808080;">&#91;</span>dbo<span style="color: #808080;">&#93;</span>.<span style="color: #808080;">&#91;</span>audit_source_DEL<span style="color: #808080;">&#93;</span>
GO
&nbsp;
<span style="color: #008080;">-- Create DELETE trigger</span>
<span style="color: #0000FF;">CREATE</span> <span style="color: #0000FF;">TRIGGER</span> audit_source_DEL
<span style="color: #0000FF;">on</span> Table_1
<span style="color: #0000FF;">FOR</span> <span style="color: #0000FF;">INSERT</span>
<span style="color: #0000FF;">AS</span>
<span style="color: #0000FF;">DECLARE</span> @command <span style="color: #0000FF;">NVARCHAR</span><span style="color: #808080;">&#40;</span><span style="color: #000;">255</span><span style="color: #808080;">&#41;</span>
&nbsp;
<span style="color: #0000FF;">if</span> <span style="color: #000;">0</span> <span style="color: #808080;">=</span> <span style="color: #808080;">&#40;</span><span style="color: #0000FF;">select</span> <span style="color: #FF00FF;">count</span><span style="color: #808080;">&#40;</span><span style="color: #808080;">*</span><span style="color: #808080;">&#41;</span> <span style="color: #0000FF;">from</span> inserted<span style="color: #808080;">&#41;</span> <span style="color: #0000FF;">return</span>
&nbsp;
<span style="color: #0000FF;">CREATE</span> <span style="color: #0000FF;">TABLE</span> #InputBuffer <span style="color: #808080;">&#40;</span><span style="color: #808080;">&#91;</span>eventtype<span style="color: #808080;">&#93;</span> <span style="color: #0000FF;">NVARCHAR</span><span style="color: #808080;">&#40;</span><span style="color: #000;">30</span><span style="color: #808080;">&#41;</span>, <span style="color: #808080;">&#91;</span><span style="color: #0000FF;">parameters</span><span style="color: #808080;">&#93;</span> <span style="color: #0000FF;">INT</span>, <span style="color: #808080;">&#91;</span>eventinfo<span style="color: #808080;">&#93;</span> <span style="color: #0000FF;">NVARCHAR</span><span style="color: #808080;">&#40;</span><span style="color: #000;">255</span><span style="color: #808080;">&#41;</span><span style="color: #808080;">&#41;</span>
<span style="color: #0000FF;">INSERT</span> <span style="color: #0000FF;">INTO</span> #InputBuffer <span style="color: #0000FF;">exec</span><span style="color: #808080;">&#40;</span><span style="color: #FF0000;">'DBCC INPUTBUFFER(@@spid) WITH NO_INFOMSGS'</span><span style="color: #808080;">&#41;</span>
<span style="color: #0000FF;">SELECT</span> @command<span style="color: #808080;">=</span>eventinfo <span style="color: #0000FF;">from</span> #InputBuffer
&nbsp;
<span style="color: #0000FF;">INSERT</span> <span style="color: #0000FF;">INTO</span> source_audit
<span style="color: #0000FF;">SELECT</span> <span style="color: #FF00FF;">getdate</span><span style="color: #808080;">&#40;</span><span style="color: #808080;">&#41;</span>, <span style="color: #FF00FF;">app_name</span><span style="color: #808080;">&#40;</span><span style="color: #808080;">&#41;</span>, <span style="color: #FF00FF;">host_name</span><span style="color: #808080;">&#40;</span><span style="color: #808080;">&#41;</span>, suser_name<span style="color: #808080;">&#40;</span><span style="color: #808080;">&#41;</span>, col1, col2, col3, col4, <span style="color: #FF0000;">'D'</span>, @command, <span style="color: #FF00FF;">@@SPID</span>
<span style="color: #0000FF;">FROM</span> deleted
GO</pre></td></tr></table></div>

<h2>Examining the results</h2>
<p>Once the audit table and triggers are in place we can begin collecting audit data.  The audit data can be exported from the audit table after reproducing the problem to be queried at a later place and time, or it can be queried directly.  Here is a sample audit of a Merge publisher and the audit data after an update and sync from subscriber <em>WS2008R2_1</em>.</p>

<div class="wp_syntax"><table><tr><td class="code"><pre class="tsql" style="font-family:monospace;"><span style="color: #0000FF;">SELECT</span> tstamp, ProgramName, hostname, suser,
col1, actiontype, inputbuffer, spid
<span style="color: #0000FF;">FROM</span> dbo.<span style="color: #202020;">source_audit</span></pre></td></tr></table></div>

<p><a href="http://www.sqlrepl.com/wp-content/uploads/2012/10/AuditResults_small1.png"><img class="alignleft size-full wp-image-2694" style="box-shadow: 0px 7px 7px #888888;" title="Audit results" src="http://www.sqlrepl.com/wp-content/uploads/2012/10/AuditResults_small1.png" alt="" width="800" height="91" /></a><br />
&nbsp;<br />
Using this approach, we can identify where data changes are coming from, who is causing them, and what the data is before and after the change.  This can be very useful information to have, especially when troubleshooting conflicts and determining where the conflicting changes are originating — but I will save that for a future post.  If you would like help implementing an auditing scheme in your Merge topology, feel free to <a href="http://www.sqlrepl.com/contact/" target="_blank">drop me a line</a> or leave a comment below.</p>
<p>-Brandon Williams (<a title="SQLREPL | Brandon Williams" href="http://www.sqlrepl.com" target="_blank">blog</a> | <a title="Connect on LinkedIn" href="http://www.linkedin.com/in/isbrandon" target="_blank">linkedin</a> | <a title="Follow me on Twitter" href="https://twitter.com/is_brandon" target="_blank">twitter</a>)</p>
<div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/sqlrepl?a=rqVJbfgp3eE:jNxe0B_dbbY:3QFJfmc7Om4"><img src="http://feeds.feedburner.com/~ff/sqlrepl?i=rqVJbfgp3eE:jNxe0B_dbbY:3QFJfmc7Om4" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/sqlrepl?a=rqVJbfgp3eE:jNxe0B_dbbY:dnMXMwOfBR0"><img src="http://feeds.feedburner.com/~ff/sqlrepl?d=dnMXMwOfBR0" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/sqlrepl?a=rqVJbfgp3eE:jNxe0B_dbbY:F7zBnMyn0Lo"><img src="http://feeds.feedburner.com/~ff/sqlrepl?i=rqVJbfgp3eE:jNxe0B_dbbY:F7zBnMyn0Lo" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/sqlrepl?a=rqVJbfgp3eE:jNxe0B_dbbY:V_sGLiPBpWU"><img src="http://feeds.feedburner.com/~ff/sqlrepl?i=rqVJbfgp3eE:jNxe0B_dbbY:V_sGLiPBpWU" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/sqlrepl?a=rqVJbfgp3eE:jNxe0B_dbbY:gIN9vFwOqvQ"><img src="http://feeds.feedburner.com/~ff/sqlrepl?i=rqVJbfgp3eE:jNxe0B_dbbY:gIN9vFwOqvQ" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/sqlrepl?a=rqVJbfgp3eE:jNxe0B_dbbY:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/sqlrepl?d=yIl2AUoC8zA" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/sqlrepl/~4/rqVJbfgp3eE" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.sqlrepl.com/sql-server/auditing-changes-in-merge-replication/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		<feedburner:origLink>http://www.sqlrepl.com/sql-server/auditing-changes-in-merge-replication/</feedburner:origLink></item>
		<item>
		<title>Implementing a replication agent progess bar</title>
		<link>http://feedproxy.google.com/~r/sqlrepl/~3/JZQIZ1BynM4/</link>
		<comments>http://www.sqlrepl.com/sql-server/implementing-a-replication-agent-progess-bar/#comments</comments>
		<pubDate>Sun, 06 May 2012 05:33:48 +0000</pubDate>
		<dc:creator>Brandon Williams</dc:creator>
				<category><![CDATA[Merge]]></category>
		<category><![CDATA[Noteworthy]]></category>
		<category><![CDATA[Replication]]></category>
		<category><![CDATA[RMO]]></category>
		<category><![CDATA[SQL Server]]></category>
		<category><![CDATA[SQLServerPedia Syndication]]></category>
		<category><![CDATA[develop]]></category>
		<category><![CDATA[implement]]></category>
		<category><![CDATA[program]]></category>

		<guid isPermaLink="false">http://www.sqlrepl.com/?p=2299</guid>
		<description><![CDATA[Using Replication Management Objects, SQL Server subscriptions can be synchronized programmatically without using SQL Server Agent or SQL Server Management Studio.  Common uses include: Express edition subscribers Sync from within an application on-demand without an agent job Display agent status information in an application In a previous post I provided a link to a code [...]]]></description>
				<content:encoded><![CDATA[<p style="text-align: left;">Using Replication Management Objects, SQL Server subscriptions can be synchronized programmatically without using SQL Server Agent or SQL Server Management Studio.  Common uses include:</p>
<ul>
<li>Express edition subscribers</li>
<li>Sync from within an application on-demand without an agent job</li>
<li>Display agent status information in an application</li>
</ul>
<p style="text-align: left;">In a previous post I provided a link to a code sample showing how to <a title="Synchronizing subscriptions in SQL Server Express" href="http://www.sqlrepl.com/sql-server/synchronizing-subscriptions-in-sql-server-express/" target="_blank">synchronize a Merge pull subscription in SQL Server Express</a> using RMO.  Taking this a step further, for this post I will discuss how to implement a Merge Agent progress bar during synchronous execution, handling the <a title="MergeSynchronizationAgent.Status Event" href="http://msdn.microsoft.com/en-us/library/microsoft.sqlserver.replication.mergesynchronizationagent.status.aspx" rel="nofollow" target="_blank">MergeSynchronizationAgent.Status</a> event and displaying the results in a Windows Form.</p>
<p><a href="http://www.sqlrepl.com/wp-content/uploads/2012/05/ExpressSubscriptionStatus2.png"><img class="wp-image-2320" style="box-shadow: 0px 7px 7px #888888;" title="Express Subscription Status" src="http://www.sqlrepl.com/wp-content/uploads/2012/05/ExpressSubscriptionStatus2.png" alt="" width="500" height="244" /></a></p>
<h2 style="text-align: left;">Synchronously synchronize asynchronously</h2>
<p style="text-align: left;">When using the <a title="MergeSynchronizationAgent.Synchronize" href="http://msdn.microsoft.com/en-us/library/microsoft.sqlserver.replication.mergesynchronizationagent.synchronize.aspx" rel="nofollow" target="_blank">MergeSynchronizationAgent.Synchronize</a> method to synchronize the Merge Agent it is important to realize that this starts the agent synchronously and control remains with the running agent until it completes.  This can make updating UI controls a bit tricky as UI events can be delayed until the Merge Agent finishes synchronizing, which is not very useful.  The key to making this work smoothly is to use a <a title="BackgroundWorker Class" href="http://msdn.microsoft.com/en-us/library/system.componentmodel.backgroundworker.aspx" rel="nofollow" target="_blank">BackgroundWorker</a> to synchronize the agent on a separate thread asynchronously and report progress back to the main UI thread when the MergeSynchronization.Status event is raised.</p>
<p style="text-align: left;"><a href="http://www.sqlrepl.com/wp-content/uploads/2012/05/BackgroundWorker15.png"><img class="aligncenter size-full wp-image-2373" title="BackgroundWorker" src="http://www.sqlrepl.com/wp-content/uploads/2012/05/BackgroundWorker15.png" alt="" width="850" height="407" /></a></p>
<p style="text-align: left;">From here the synchronization <a title="BackgroundWorker.DoWork Event" href="http://msdn.microsoft.com/en-us/library/system.componentmodel.backgroundworker.dowork.aspx" rel="nofollow" target="_blank">BackgroundWorker.DoWork</a> event handler can subscribe to the MergeSynchronizationAgent.Status event and start the Merge Agent synchronously for a specified subscription.</p>
<p style="text-align: left;"><a href="http://www.sqlrepl.com/wp-content/uploads/2012/05/Synchronize1.png"><img class="aligncenter size-full wp-image-2383" title="Synchronize" src="http://www.sqlrepl.com/wp-content/uploads/2012/05/Synchronize1.png" alt="" width="850" height="382" /></a></p>
<h2 style="text-align: left;">Status Event</h2>
<p style="text-align: left;">The MergeSynchronizationAgent.Status event handler reports the Merge Agent progress passing <a title="StatusEventArgs Class" href="http://msdn.microsoft.com/en-us/library/microsoft.sqlserver.replication.statuseventargs.aspx" rel="nofollow" target="_blank">StatusEventArgs</a> <em>PercentCompleted</em> and <em>Message</em> back to the main UI thread which is handled by the synchronization <a title="BackgroundWorker.ProgressChanged Event" href="http://msdn.microsoft.com/en-us/library/system.componentmodel.backgroundworker.progresschanged.aspx" rel="nofollow" target="_blank">BackgroundWorker.ProgressChanged</a> event handler.</p>
<p style="text-align: left;"><a href="http://www.sqlrepl.com/wp-content/uploads/2012/05/StatusEventHandler1.png"><img class="aligncenter size-full wp-image-2387" title="Status Event Handler" src="http://www.sqlrepl.com/wp-content/uploads/2012/05/StatusEventHandler1.png" alt="" width="850" height="108" /></a></p>
<h2 style="text-align: left;">ProgressChanged Event</h2>
<p style="text-align: left;">Finally, the synchronization BackgroundWorker.ProgressChanged event handler smoothly updates the progress bar and text box controls according to the Merge Agent status.</p>
<p style="text-align: left;"><a href="http://www.sqlrepl.com/wp-content/uploads/2012/05/ProgressChangedEventHandler2.png"><img class="aligncenter size-full wp-image-2392" title="ProgressChanged Event Handler" src="http://www.sqlrepl.com/wp-content/uploads/2012/05/ProgressChangedEventHandler2.png" alt="" width="850" height="218" /></a></p>
<h2 style="text-align: left;">Sample</h2>
<p style="text-align: left;">This code sample can be downloaded from the MSDN Code Gallery:</p>
<ul>
<li><strong><a title="SQL Server Express — Merge Pull Subscription Progress Bar (RMO Programming)" href="http://code.msdn.microsoft.com/SQL-Server-Express-Merge-4e01e119" rel="nofollow" target="_blank">SQL Server Express — Merge Pull Subscription Progress Bar (RMO Programming)</a></strong></li>
</ul>
<p style="text-align: left;">If you have any questions about the sample, or would like help integrating this into your application, feel free to <a title="ping" href="http://www.sqlrepl.com/contact/" target="_blank">ping me</a> or leave a comment below.</p>
<p style="text-align: left;">-Brandon Williams (<a title="SQLREPL | Brandon Williams" href="http://www.sqlrepl.com" target="_blank">blog</a> | <a title="Connect on LinkedIn" href="http://www.linkedin.com/in/isbrandon" target="_blank">linkedin</a> | <a title="Follow me on Twitter" href="https://twitter.com/is_brandon" target="_blank">twitter</a>)</p>
<div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/sqlrepl?a=JZQIZ1BynM4:G_BzHRDrtQM:3QFJfmc7Om4"><img src="http://feeds.feedburner.com/~ff/sqlrepl?i=JZQIZ1BynM4:G_BzHRDrtQM:3QFJfmc7Om4" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/sqlrepl?a=JZQIZ1BynM4:G_BzHRDrtQM:dnMXMwOfBR0"><img src="http://feeds.feedburner.com/~ff/sqlrepl?d=dnMXMwOfBR0" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/sqlrepl?a=JZQIZ1BynM4:G_BzHRDrtQM:F7zBnMyn0Lo"><img src="http://feeds.feedburner.com/~ff/sqlrepl?i=JZQIZ1BynM4:G_BzHRDrtQM:F7zBnMyn0Lo" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/sqlrepl?a=JZQIZ1BynM4:G_BzHRDrtQM:V_sGLiPBpWU"><img src="http://feeds.feedburner.com/~ff/sqlrepl?i=JZQIZ1BynM4:G_BzHRDrtQM:V_sGLiPBpWU" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/sqlrepl?a=JZQIZ1BynM4:G_BzHRDrtQM:gIN9vFwOqvQ"><img src="http://feeds.feedburner.com/~ff/sqlrepl?i=JZQIZ1BynM4:G_BzHRDrtQM:gIN9vFwOqvQ" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/sqlrepl?a=JZQIZ1BynM4:G_BzHRDrtQM:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/sqlrepl?d=yIl2AUoC8zA" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/sqlrepl/~4/JZQIZ1BynM4" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.sqlrepl.com/sql-server/implementing-a-replication-agent-progess-bar/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
		<feedburner:origLink>http://www.sqlrepl.com/sql-server/implementing-a-replication-agent-progess-bar/</feedburner:origLink></item>
		<item>
		<title>PASS DBA Virtual Chapter: Replication with Hilary Cotter</title>
		<link>http://feedproxy.google.com/~r/sqlrepl/~3/CuPJa0Ba0Mg/</link>
		<comments>http://www.sqlrepl.com/sql-server/pass-dba-virtual-chapter-replication-with-hilary-cotter/#comments</comments>
		<pubDate>Tue, 10 Apr 2012 03:52:29 +0000</pubDate>
		<dc:creator>Brandon Williams</dc:creator>
				<category><![CDATA[Replication]]></category>
		<category><![CDATA[SQL Server]]></category>
		<category><![CDATA[SQLServerPedia Syndication]]></category>
		<category><![CDATA[administration]]></category>

		<guid isPermaLink="false">http://www.sqlrepl.com/?p=2267</guid>
		<description><![CDATA[I’m pleased to announce that this Wednesday April 11th 2012 Hilary Cotter will be presenting for the PASS DBA Virtual Chapter on SQL Server Replication.  Replication is a powerful and flexible data distribution solution that has become one of the more mature features in SQL Server.  Come listen to Microsoft MVP and replication expert Hilary [...]]]></description>
				<content:encoded><![CDATA[<p>I’m pleased to announce that this Wednesday April 11th 2012 Hilary Cotter will be presenting for the PASS DBA Virtual Chapter on SQL Server Replication.  Replication is a powerful and flexible data distribution solution that has become one of the more mature features in SQL Server.  Come listen to Microsoft MVP and replication expert Hilary Cotter discuss SQL Server Replication.  We should be in for a treat and I hope to see you all there.</p>
<p><span style="text-decoration: underline;">PASS DBA Virtual Chapter Live Meeting Event</span>:  <a title="PASS DBA Virtual Chapter" href="http://dba.sqlpass.org/" target="_blank">http://dba.sqlpass.org/</a></p>
<p><strong>Date and time:</strong>  April 11th 2012 12:00 pm Mountain time</p>
<blockquote><p><strong>Topic:</strong>  SQL Server Replication – sponsored by Quest Software</p>
<p><strong>Presenter:</strong>  Hilary Cotter</p>
<p><strong>Abstract:</strong>  Replication is a native SQL Server component which allows you to copy data from one database or server to another and can be configured to replicate bi-directionally.  In this webcast, SQL Server MVP., Hilary Cotter discusses replication types as well as common use cases and problems, as well as troubleshooting and monitoring and how to squeeze optimal performance from merge, transactional and bi-directional replication.</p>
<p><strong>Bio:</strong>  Hilary Cotter is an industry veteran and has been a SQL Server MVP for 11 years. He specializes in replication, full-text search and SQL Server Service Broker. He has worked for many fortune 500 companies implementing cutting edge replication solutions. He has written and co-authored several books.</p></blockquote>
<p><strong>Live Meeting link:</strong>  The Live Meeting link for the webcast and meeting archive can be found on the <a title="PASS DBA Virtual Chapter" href="http://dba.sqlpass.org/" target="_blank">PASS DBA Virtual Chapter website</a>.</p>
<div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/sqlrepl?a=CuPJa0Ba0Mg:iBZ9cYotUcI:3QFJfmc7Om4"><img src="http://feeds.feedburner.com/~ff/sqlrepl?i=CuPJa0Ba0Mg:iBZ9cYotUcI:3QFJfmc7Om4" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/sqlrepl?a=CuPJa0Ba0Mg:iBZ9cYotUcI:dnMXMwOfBR0"><img src="http://feeds.feedburner.com/~ff/sqlrepl?d=dnMXMwOfBR0" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/sqlrepl?a=CuPJa0Ba0Mg:iBZ9cYotUcI:F7zBnMyn0Lo"><img src="http://feeds.feedburner.com/~ff/sqlrepl?i=CuPJa0Ba0Mg:iBZ9cYotUcI:F7zBnMyn0Lo" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/sqlrepl?a=CuPJa0Ba0Mg:iBZ9cYotUcI:V_sGLiPBpWU"><img src="http://feeds.feedburner.com/~ff/sqlrepl?i=CuPJa0Ba0Mg:iBZ9cYotUcI:V_sGLiPBpWU" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/sqlrepl?a=CuPJa0Ba0Mg:iBZ9cYotUcI:gIN9vFwOqvQ"><img src="http://feeds.feedburner.com/~ff/sqlrepl?i=CuPJa0Ba0Mg:iBZ9cYotUcI:gIN9vFwOqvQ" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/sqlrepl?a=CuPJa0Ba0Mg:iBZ9cYotUcI:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/sqlrepl?d=yIl2AUoC8zA" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/sqlrepl/~4/CuPJa0Ba0Mg" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.sqlrepl.com/sql-server/pass-dba-virtual-chapter-replication-with-hilary-cotter/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		<feedburner:origLink>http://www.sqlrepl.com/sql-server/pass-dba-virtual-chapter-replication-with-hilary-cotter/</feedburner:origLink></item>
		<item>
		<title>Synchronizing subscriptions in SQL Server Express</title>
		<link>http://feedproxy.google.com/~r/sqlrepl/~3/LtpNciNPxTg/</link>
		<comments>http://www.sqlrepl.com/sql-server/synchronizing-subscriptions-in-sql-server-express/#comments</comments>
		<pubDate>Mon, 12 Mar 2012 07:53:23 +0000</pubDate>
		<dc:creator>Brandon Williams</dc:creator>
				<category><![CDATA[Merge]]></category>
		<category><![CDATA[Noteworthy]]></category>
		<category><![CDATA[Replication]]></category>
		<category><![CDATA[RMO]]></category>
		<category><![CDATA[SQL Server]]></category>
		<category><![CDATA[SQLServerPedia Syndication]]></category>
		<category><![CDATA[administration]]></category>
		<category><![CDATA[develop]]></category>
		<category><![CDATA[implement]]></category>
		<category><![CDATA[profile]]></category>
		<category><![CDATA[program]]></category>

		<guid isPermaLink="false">http://www.sqlrepl.com/?p=2109</guid>
		<description><![CDATA[I was recently asked about synchronizing a Merge pull subscription in SQL Server Express using RMO, the lack of a SQL Server Agent, and what to do about it.  Since SQL Server Express does not include the SQL Server Agent, pull subscriptions must be synchronized by some other means.  The problem becomes evident when trying [...]]]></description>
				<content:encoded><![CDATA[<p>I was recently asked about synchronizing a Merge pull subscription in SQL Server Express using RMO, the lack of a SQL Server Agent, and what to do about it.  Since SQL Server Express does not include the SQL Server Agent, pull subscriptions must be synchronized by some other means.  The problem becomes evident when trying to open the <em>View Synchronization Status</em> dialog for a pull subscription in SQL Server Express.</p>
<p><a href="http://www.sqlrepl.com/wp-content/uploads/2012/03/viewsyncstatus2.png"><img class="aligncenter size-full wp-image-2110" title="View Synchronization Status" alt="View Synchronization Status" src="http://www.sqlrepl.com/wp-content/uploads/2012/03/viewsyncstatus2.png" width="625" height="199" /></a></p>
<p>The <em>View Synchronization Status</em> dialog depends on a SQL Server Agent job which does not exist in SQL Server Express.  To accommodate for the lack of a SQL Server Agent, SQL Server Express Merge pull subscriptions can also be synchronized by executing batch scripts, Windows Synchronization Manager, or Replication Management Objects (RMO).  While not optimal without the SQL Server Agent, plenty of options are available. This is where it really pays to know the different ways a subscription can be synchronized when tasked with an Express subscriber.</p>
<h2>Batch script</h2>
<p>The <a title="Replication Merge Agent" href="http://msdn.microsoft.com/en-us/library/ms147839.aspx" target="_blank">Merge Agent</a> (replmerg.exe) executable can be run from the command line on-demand or from a batch script as a scheduled task.  To run from the command line, execute replmerg.exe from the COM folder.</p>
<p><a href="http://www.sqlrepl.com/wp-content/uploads/2012/03/replmerg_exe.png"><img class="aligncenter size-full wp-image-2111" title="replmerg.exe" alt="replmerg.exe" src="http://www.sqlrepl.com/wp-content/uploads/2012/03/replmerg_exe.png" width="645" height="92" /></a></p>
<p>Likewise, this can be saved as a batch file and run from Task Scheduler on a schedule.  This option alone provides a pretty good replacement for the SQL Server Agent and synchronizing subscriptions in Express.</p>
<h2>Windows Synchronization Manager</h2>
<p>Another option to synchronize pull subscriptions in SQL Server Express is <a title="Windows Synchronization Manager" href="http://msdn.microsoft.com/en-us/library/ms151863.aspx" target="_blank">Windows Synchronization Manager</a>, or <a title="Sync Center" href="http://msdn.microsoft.com/en-us/library/aa369140(v=vs.85).aspx" target="_blank">Sync Center</a>.  Sync Center provides options for setting and viewing sync partnerships, setting subscription properties and sync schedules, and viewing sync results and conflicts.  This tool is ideal for having non-technical users synchronize SQL Server Express pull subscriptions on-demand as it offers a user-friendly interface.  Synchronization schedules can also be configured as needed.</p>
<p style="text-align: center;"><a href="http://www.sqlrepl.com/wp-content/uploads/2012/03/wsm2.png"><img class="wp-image-2112 aligncenter" title="Windows Synchronization Manager" alt="Windows Synchronization Manager" src="http://www.sqlrepl.com/wp-content/uploads/2012/03/wsm2.png" width="860" height="181" /></a></p>
<h2>RMO</h2>
<p>For all the developers, Replication Management Objects (RMO) can be used to synchronize SQL Server Express Merge pull subscriptions through managed code access.  The RMO <a title="MergeSynchronizationAgent" href="http://msdn.microsoft.com/en-us/library/microsoft.sqlserver.replication.mergesynchronizationagent.aspx" target="_blank">MergeSynchronizationAgent</a> class exposes a <a title="Synchronize" href="http://msdn.microsoft.com/en-us/library/microsoft.sqlserver.replication.mergesynchronizationagent.synchronize.aspx" target="_blank">Synchronize</a> method which can be used to synchronize a subscription without an agent job — additional properties must be supplied.  A code sample demonstrating how to synchronize a SQL Server Express Merge pull subscription using RMO can be downloaded from the <a title="MSDN Code Gallery" href="http://code.msdn.microsoft.com/SQL-Server-Express-05c73322" target="_blank">MSDN Code Gallery</a>.</p>
<h2>So</h2>
<p>As we can see, there are options for synchronizing pull subscriptions in SQL Server Express.  That is because Replication was built with SQL Server Express subscribers in mind.  Pull subscriptions can be synchronized using batch scripts, Windows Synchronization Manager, and RMO which should be sufficient enough to synchronize the data.  If you happen to know of another way to synchronize SQL Server Express pull subscriptions and would like to share, feel free to leave a comment below.</p>
<div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/sqlrepl?a=LtpNciNPxTg:-OZ_gO2-79I:3QFJfmc7Om4"><img src="http://feeds.feedburner.com/~ff/sqlrepl?i=LtpNciNPxTg:-OZ_gO2-79I:3QFJfmc7Om4" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/sqlrepl?a=LtpNciNPxTg:-OZ_gO2-79I:dnMXMwOfBR0"><img src="http://feeds.feedburner.com/~ff/sqlrepl?d=dnMXMwOfBR0" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/sqlrepl?a=LtpNciNPxTg:-OZ_gO2-79I:F7zBnMyn0Lo"><img src="http://feeds.feedburner.com/~ff/sqlrepl?i=LtpNciNPxTg:-OZ_gO2-79I:F7zBnMyn0Lo" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/sqlrepl?a=LtpNciNPxTg:-OZ_gO2-79I:V_sGLiPBpWU"><img src="http://feeds.feedburner.com/~ff/sqlrepl?i=LtpNciNPxTg:-OZ_gO2-79I:V_sGLiPBpWU" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/sqlrepl?a=LtpNciNPxTg:-OZ_gO2-79I:gIN9vFwOqvQ"><img src="http://feeds.feedburner.com/~ff/sqlrepl?i=LtpNciNPxTg:-OZ_gO2-79I:gIN9vFwOqvQ" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/sqlrepl?a=LtpNciNPxTg:-OZ_gO2-79I:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/sqlrepl?d=yIl2AUoC8zA" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/sqlrepl/~4/LtpNciNPxTg" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.sqlrepl.com/sql-server/synchronizing-subscriptions-in-sql-server-express/feed/</wfw:commentRss>
		<slash:comments>8</slash:comments>
		<feedburner:origLink>http://www.sqlrepl.com/sql-server/synchronizing-subscriptions-in-sql-server-express/</feedburner:origLink></item>
		<item>
		<title>Executing scripts with sp_addscriptexec</title>
		<link>http://feedproxy.google.com/~r/sqlrepl/~3/uCy5em-SFCM/</link>
		<comments>http://www.sqlrepl.com/sql-server/executing-scripts-with-sp_addscriptexec/#comments</comments>
		<pubDate>Fri, 10 Feb 2012 06:42:47 +0000</pubDate>
		<dc:creator>Brandon Williams</dc:creator>
				<category><![CDATA[Merge]]></category>
		<category><![CDATA[Noteworthy]]></category>
		<category><![CDATA[Replication]]></category>
		<category><![CDATA[SQL Server]]></category>
		<category><![CDATA[SQLServerPedia Syndication]]></category>
		<category><![CDATA[Transactional]]></category>
		<category><![CDATA[administration]]></category>
		<category><![CDATA[implement]]></category>
		<category><![CDATA[plan]]></category>

		<guid isPermaLink="false">http://www.sqlrepl.com/?p=2013</guid>
		<description><![CDATA[Looking for ways to do things more quickly and efficiently, I thought I would talk a little bit about sp_addscriptexec and how it can be leveraged to expedite the process of executing SQL scripts in a replication topology.  By creating and saving a SQL script on a publisher, it can then be distributed to and [...]]]></description>
				<content:encoded><![CDATA[<p>Looking for ways to do things more quickly and efficiently, I thought I would talk a little bit about sp_addscriptexec and how it can be leveraged to expedite the process of executing SQL scripts in a replication topology.  By creating and saving a SQL script on a publisher, it can then be distributed to and executed on UNC/FTP deployed subscribers using sp_addscriptexec.</p>
<p>The syntax for <a title="sp_addscriptexec" href="http://msdn.microsoft.com/en-us/library/ms174360.aspx" rel="nofollow" target="_blank">sp_addscriptexec</a> per BOL</p>
<blockquote><p>sp_addscriptexec [ @publication = ] publication<br />
[ , [ @scriptfile = ] 'scriptfile' ]<br />
[ , [ @skiperror = ] 'skiperror' ]<br />
[ , [ @publisher = ] 'publisher' ]</p></blockquote>
<h2>The problem with numbers</h2>
<p>If you’re dealing with a large number of subscribers, database administration can be tricky.  Tasks such as adding logins and users, granting permissions, maintaining indexes, and managing constraints must be done individually at each node and deploying all of the scripts can be very time consuming.  Rather than visit each node, sp_addscriptexec should be used to post the ad-hoc script to all subscribers in the topology, saving valuable time.  Put simply – if you’re visiting each node to execute a script, you’re doing it wrong.</p>
<p>The benefit with using sp_addscriptexec is that the publisher can act as a centralized script repository.  Scripts can be saved to the publisher and executed on demand for subscribers.  This process is quicker and more efficient than copying, saving, and executing scripts directly at each subscriber.  Not only does this save time, but space as well.</p>
<h2>Executing scripts</h2>
<p>Applying scripts to subscribers from the publisher can be done by:</p>
<ul>
<li>Create and test the script</li>
<li>Save the script to the publisher</li>
<li>Execute sp_addscriptexec at the publisher to apply script to subscribers</li>
</ul>
<p>From here, the script will be executed at each subscriber on the next synchronization.  Taking this one step further — to limit a script to run on only certain subscribers, a check for HOST_NAME can be performed in the script.</p>

<div class="wp_syntax"><table><tr><td class="code"><pre class="tsql" style="font-family:monospace;"><span style="color: #008080;">-- Limit script to Subscriber1, Subscriber2, and Subscriber3</span>
<span style="color: #0000FF;">IF</span> <span style="color: #FF00FF;">HOST_NAME</span><span style="color: #808080;">&#40;</span><span style="color: #808080;">&#41;</span> <span style="color: #808080;">IN</span> <span style="color: #808080;">&#40;</span><span style="color: #FF0000;">'Subscriber1'</span>, <span style="color: #FF0000;">'Subscriber2'</span>, <span style="color: #FF0000;">'Subscriber3'</span><span style="color: #808080;">&#41;</span>
	<span style="color: #008080;">-- script goes here</span></pre></td></tr></table></div>

<h2>Something to consider</h2>
<p>A caveat with sp_addscriptexec is that by default, if the script being executed encounters an error at the subscriber, the replication agent will fail and retry on subsequent syncs in an endless loop, be aware of this.  This behavior can be overridden by passing a value of 1 for <strong>@skiperror</strong> which instructs the agent to skip errors.  At the very least, SQL scripts should be tested thoroughly at the publisher before calling sp_addscriptexec to apply them to subscribers.</p>
<div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/sqlrepl?a=uCy5em-SFCM:WWV8SwyWhe4:3QFJfmc7Om4"><img src="http://feeds.feedburner.com/~ff/sqlrepl?i=uCy5em-SFCM:WWV8SwyWhe4:3QFJfmc7Om4" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/sqlrepl?a=uCy5em-SFCM:WWV8SwyWhe4:dnMXMwOfBR0"><img src="http://feeds.feedburner.com/~ff/sqlrepl?d=dnMXMwOfBR0" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/sqlrepl?a=uCy5em-SFCM:WWV8SwyWhe4:F7zBnMyn0Lo"><img src="http://feeds.feedburner.com/~ff/sqlrepl?i=uCy5em-SFCM:WWV8SwyWhe4:F7zBnMyn0Lo" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/sqlrepl?a=uCy5em-SFCM:WWV8SwyWhe4:V_sGLiPBpWU"><img src="http://feeds.feedburner.com/~ff/sqlrepl?i=uCy5em-SFCM:WWV8SwyWhe4:V_sGLiPBpWU" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/sqlrepl?a=uCy5em-SFCM:WWV8SwyWhe4:gIN9vFwOqvQ"><img src="http://feeds.feedburner.com/~ff/sqlrepl?i=uCy5em-SFCM:WWV8SwyWhe4:gIN9vFwOqvQ" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/sqlrepl?a=uCy5em-SFCM:WWV8SwyWhe4:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/sqlrepl?d=yIl2AUoC8zA" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/sqlrepl/~4/uCy5em-SFCM" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.sqlrepl.com/sql-server/executing-scripts-with-sp_addscriptexec/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		<feedburner:origLink>http://www.sqlrepl.com/sql-server/executing-scripts-with-sp_addscriptexec/</feedburner:origLink></item>
		<item>
		<title>Arithmetic Overflow in sp_MSarticle_validation</title>
		<link>http://feedproxy.google.com/~r/sqlrepl/~3/2aKkxGBu-x4/</link>
		<comments>http://www.sqlrepl.com/sql-server/arithmetic-overflow-in-sp_msarticle_validation/#comments</comments>
		<pubDate>Tue, 07 Feb 2012 05:49:31 +0000</pubDate>
		<dc:creator>Brandon Williams</dc:creator>
				<category><![CDATA[Noteworthy]]></category>
		<category><![CDATA[Replication]]></category>
		<category><![CDATA[SQL Server]]></category>
		<category><![CDATA[SQLServerPedia Syndication]]></category>
		<category><![CDATA[Transactional]]></category>
		<category><![CDATA[error]]></category>
		<category><![CDATA[microsoft connect]]></category>
		<category><![CDATA[troubleshoot]]></category>

		<guid isPermaLink="false">http://www.sqlrepl.com/?p=1925</guid>
		<description><![CDATA[This is probably a rare occurrence — but I've noticed that data validation for an article with 10 billion or more rows will fail due to an arithmetic overflow error in sp_MSarticle_validation. Data validation for a specific article in a transactional publication is done using sp_article_validation which in turn calls sp_MSarticle_validation.  In the definition of sp_MSarticle_validation, [...]]]></description>
				<content:encoded><![CDATA[<p>This is probably a rare occurrence — but I've noticed that data validation for an article with 10 billion or more rows will fail due to an arithmetic overflow error in <a title="sp_MSarticle_validation" href="http://www.g-productions.nl/index.php?name=sp_MSarticle_validation&amp;version=2008RTM" rel="nofollow" target="_blank"><em>sp_MSarticle_validation</em></a>.</p>
<p>Data validation for a specific article in a transactional publication is done using <em><a title="sp_article_validation" href="http://msdn.microsoft.com/en-us/library/ms177511.aspx" rel="nofollow" target="_blank">sp_article_validation</a></em> which in turn calls <em>sp_MSarticle_validation</em>.  In the definition of <em>sp_MSarticle_validation</em>, a local variable named <strong>@actual_rowcount</strong> is defined which is of the type <strong>bigint</strong>.  Later on in <em>sp_MSarticle_validation</em>, a command is built to execute <em><a title="sp_table_validation" href="http://msdn.microsoft.com/en-us/library/ms176092.aspx" rel="nofollow" target="_blank">sp_table_validation</a></em> and the <strong>@expected_rowcount</strong> parameter passed in is derived by converting <strong>@actual_rowcount</strong> to a <strong>varchar(10)</strong>.</p>
<p>The offending statement can be observed in the following code snippet from <em>sp_MSarticle_validation</em>:</p>

<div class="wp_syntax"><table><tr><td class="code"><pre class="tsql" style="font-family:monospace;"><span style="color: #0000FF;">select</span> @command <span style="color: #808080;">=</span> <span style="color: #FF0000;">'exec dbo.sp_table_validation @table = '</span><span style="color: #FF0000;">''</span> <span style="color: #808080;">+</span> <span style="color: #FF00FF;">replace</span><span style="color: #808080;">&#40;</span>@destination_table, <span style="color: #FF0000;">''</span><span style="color: #FF0000;">''</span>, <span style="color: #FF0000;">''</span><span style="color: #FF0000;">''</span><span style="color: #FF0000;">''</span><span style="color: #808080;">&#41;</span>  <span style="color: #808080;">+</span> <span style="color: #FF0000;">''</span><span style="color: #FF0000;">', @expected_rowcount = '</span> <span style="color: #808080;">+</span>
	        <span style="color: #0000FF;">convert</span><span style="color: #808080;">&#40;</span><span style="color: #0000FF;">varchar</span><span style="color: #808080;">&#40;</span><span style="color: #000;">10</span><span style="color: #808080;">&#41;</span>, @actual_rowcount<span style="color: #808080;">&#41;</span> <span style="color: #808080;">+</span> <span style="color: #FF0000;">', @expected_checksum = '</span> <span style="color: #808080;">+</span>
	        <span style="color: #0000FF;">convert</span><span style="color: #808080;">&#40;</span><span style="color: #0000FF;">varchar</span><span style="color: #808080;">&#40;</span><span style="color: #000;">100</span><span style="color: #808080;">&#41;</span>, @actual_checksum<span style="color: #808080;">&#41;</span> <span style="color: #808080;">+</span> <span style="color: #FF0000;">', @rowcount_only = '</span> <span style="color: #808080;">+</span> <span style="color: #0000FF;">convert</span><span style="color: #808080;">&#40;</span><span style="color: #0000FF;">varchar</span><span style="color: #808080;">&#40;</span><span style="color: #000;">5</span><span style="color: #808080;">&#41;</span>,@rowcount_only<span style="color: #808080;">&#41;</span> <span style="color: #808080;">+</span>
	        <span style="color: #FF0000;">', @full_or_fast = '</span> <span style="color: #808080;">+</span> <span style="color: #0000FF;">convert</span><span style="color: #808080;">&#40;</span><span style="color: #0000FF;">varchar</span><span style="color: #808080;">&#40;</span><span style="color: #000;">10</span><span style="color: #808080;">&#41;</span>, @full_or_fast<span style="color: #808080;">&#41;</span> <span style="color: #808080;">+</span>
	        <span style="color: #FF0000;">', @shutdown_agent = '</span> <span style="color: #808080;">+</span> <span style="color: #0000FF;">convert</span><span style="color: #808080;">&#40;</span><span style="color: #0000FF;">varchar</span><span style="color: #808080;">&#40;</span><span style="color: #000;">10</span><span style="color: #808080;">&#41;</span>, @shutdown_agent<span style="color: #808080;">&#41;</span></pre></td></tr></table></div>

<p>Considering <strong>@actual_rowcount</strong> is a <strong>bigint</strong>, it should be converted to a <strong>varchar(19)</strong>, rather than a <strong>varchar(10)</strong>.  This is where an arithmetic overflow error occurs when validating an article that has 10 billion or more rows, causing validation to fail.</p>
<p>If you find yourself needing to validate an article with 10 billion or more rows, please <a title="Microsoft Connect" href="https://connect.microsoft.com/SQLServer/feedback/details/723133/arithmetic-overflow-in-sp-msarticle-validation" rel="nofollow" target="_blank">vote this item as important</a> to expedite a fix.</p>
<div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/sqlrepl?a=2aKkxGBu-x4:Th5Ch6REjTk:3QFJfmc7Om4"><img src="http://feeds.feedburner.com/~ff/sqlrepl?i=2aKkxGBu-x4:Th5Ch6REjTk:3QFJfmc7Om4" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/sqlrepl?a=2aKkxGBu-x4:Th5Ch6REjTk:dnMXMwOfBR0"><img src="http://feeds.feedburner.com/~ff/sqlrepl?d=dnMXMwOfBR0" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/sqlrepl?a=2aKkxGBu-x4:Th5Ch6REjTk:F7zBnMyn0Lo"><img src="http://feeds.feedburner.com/~ff/sqlrepl?i=2aKkxGBu-x4:Th5Ch6REjTk:F7zBnMyn0Lo" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/sqlrepl?a=2aKkxGBu-x4:Th5Ch6REjTk:V_sGLiPBpWU"><img src="http://feeds.feedburner.com/~ff/sqlrepl?i=2aKkxGBu-x4:Th5Ch6REjTk:V_sGLiPBpWU" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/sqlrepl?a=2aKkxGBu-x4:Th5Ch6REjTk:gIN9vFwOqvQ"><img src="http://feeds.feedburner.com/~ff/sqlrepl?i=2aKkxGBu-x4:Th5Ch6REjTk:gIN9vFwOqvQ" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/sqlrepl?a=2aKkxGBu-x4:Th5Ch6REjTk:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/sqlrepl?d=yIl2AUoC8zA" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/sqlrepl/~4/2aKkxGBu-x4" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.sqlrepl.com/sql-server/arithmetic-overflow-in-sp_msarticle_validation/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://www.sqlrepl.com/sql-server/arithmetic-overflow-in-sp_msarticle_validation/</feedburner:origLink></item>
		<item>
		<title>Creating merge replication conflict alerts</title>
		<link>http://feedproxy.google.com/~r/sqlrepl/~3/AQvEiGR_bNY/</link>
		<comments>http://www.sqlrepl.com/sql-server/creating-mergereplication-conflict-alerts/#comments</comments>
		<pubDate>Sat, 28 Jan 2012 19:05:26 +0000</pubDate>
		<dc:creator>Brandon Williams</dc:creator>
				<category><![CDATA[Merge]]></category>
		<category><![CDATA[Noteworthy]]></category>
		<category><![CDATA[SQL Server]]></category>
		<category><![CDATA[SQLServerPedia Syndication]]></category>
		<category><![CDATA[administration]]></category>
		<category><![CDATA[conflicts]]></category>
		<category><![CDATA[implement]]></category>
		<category><![CDATA[plan]]></category>
		<category><![CDATA[troubleshoot]]></category>

		<guid isPermaLink="false">http://www.sqlrepl.com/?p=1864</guid>
		<description><![CDATA[One of the challenges in working with Merge Replication is handling conflicts since writes can occur at any node in a topology. In an earlier post I demonstrated how to handle conflicts using the business logic handler framework - now I would like to show how to create Merge Replication conflict alerts based on the [...]]]></description>
				<content:encoded><![CDATA[<p>One of the challenges in working with Merge Replication is handling conflicts since writes can occur at any node in a topology. In an earlier post I demonstrated <a title="Merge Business Logic Handler Custom Conflict Resolver" href="http://www.sqlrepl.com/sql-server/merge-business-logic-handler-custom-conflict-resolver/">how to handle conflicts using the business logic handler framework</a> - now I would like to show how to create Merge Replication conflict alerts based on the Performance Monitor counter <strong>SQLServer:Replication Merge Conflicts/sec</strong>.</p>
<p>Ideally proper planning would be done in an application to minimize the chances of conflicts occurring, whether that is achieved through column-level tracking, partitioning the writes, filtering, or some combination.  However sometimes application changes can introduce conflicts and having alerts in place is a smart precaution to take.</p>
<p>To setup a conflict alert - identify the Performance Monitor counter <strong>SQLServer:Replication Merge Conflicts/sec</strong> instance name to monitor.  In the <em>Add Counters</em> dialog in Performance Monitor the instance name can be identified for the Merge conflicts counter for a publication:</p>
<p><a href="http://www.sqlrepl.com/wp-content/uploads/2012/01/AddCounterDialog.png"><img class="aligncenter size-full wp-image-1873" title="Add Counters Dialog" src="http://www.sqlrepl.com/wp-content/uploads/2012/01/AddCounterDialog.png" alt="Add Counters Dialog" width="715" height="527" /></a></p>
<p>For this example the instance name that I will monitori is <em>WS2008R2_1-AdventureWorksLT-TestMergePub1-WS2008R2_1-49</em>.</p>
<p>From here <a title="sp_add_alert" href="http://msdn.microsoft.com/en-us/library/ms189531.aspx" rel="nofollow" target="_blank">sp_add_alert</a> can be used to specify a merge conflict performance condition using our instance name to alert us when a conflict arises.  This can be done with the following bit of T-SQL:</p>

<div class="wp_syntax"><table><tr><td class="code"><pre class="tsql" style="font-family:monospace;"><span style="color: #0000FF;">USE</span> msdb
GO
&nbsp;
<span style="color: #0000FF;">EXEC</span> <span style="color: #AF0000;">sp_add_alert</span> @name<span style="color: #808080;">=</span>N<span style="color: #FF0000;">'Merge Conflict Alert'</span>,
        @message_id<span style="color: #808080;">=</span><span style="color: #000;">0</span>,
        @severity<span style="color: #808080;">=</span><span style="color: #000;">0</span>,
        @enabled<span style="color: #808080;">=</span><span style="color: #000;">1</span>,
        @delay_between_responses<span style="color: #808080;">=</span><span style="color: #000;">0</span>,
        @include_event_description_in<span style="color: #808080;">=</span><span style="color: #000;">0</span>,
        @category_name<span style="color: #808080;">=</span>N<span style="color: #FF0000;">'[Uncategorized]'</span>,
        @performance_condition<span style="color: #808080;">=</span>N<span style="color: #FF0000;">'SQLServer:Replication Merge|Conflicts/sec|WS2008R2_1-AdventureWorksLT-TestMergePub1-WS2008R2_1-49|&amp;gt;|0'</span></pre></td></tr></table></div>

<p>This can also be modified to raise alerts only when a certain threshold is met to suit your needs.  An alert response can be set to send an email when the conflict performance condition is met which would give a much needed heads-up when things start to go awry.  I hope this provides a technique to detect precisely when conflicts occur and a head start on tracking down the culprit.</p>
<div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/sqlrepl?a=AQvEiGR_bNY:akFrMYlILyQ:3QFJfmc7Om4"><img src="http://feeds.feedburner.com/~ff/sqlrepl?i=AQvEiGR_bNY:akFrMYlILyQ:3QFJfmc7Om4" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/sqlrepl?a=AQvEiGR_bNY:akFrMYlILyQ:dnMXMwOfBR0"><img src="http://feeds.feedburner.com/~ff/sqlrepl?d=dnMXMwOfBR0" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/sqlrepl?a=AQvEiGR_bNY:akFrMYlILyQ:F7zBnMyn0Lo"><img src="http://feeds.feedburner.com/~ff/sqlrepl?i=AQvEiGR_bNY:akFrMYlILyQ:F7zBnMyn0Lo" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/sqlrepl?a=AQvEiGR_bNY:akFrMYlILyQ:V_sGLiPBpWU"><img src="http://feeds.feedburner.com/~ff/sqlrepl?i=AQvEiGR_bNY:akFrMYlILyQ:V_sGLiPBpWU" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/sqlrepl?a=AQvEiGR_bNY:akFrMYlILyQ:gIN9vFwOqvQ"><img src="http://feeds.feedburner.com/~ff/sqlrepl?i=AQvEiGR_bNY:akFrMYlILyQ:gIN9vFwOqvQ" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/sqlrepl?a=AQvEiGR_bNY:akFrMYlILyQ:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/sqlrepl?d=yIl2AUoC8zA" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/sqlrepl/~4/AQvEiGR_bNY" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.sqlrepl.com/sql-server/creating-mergereplication-conflict-alerts/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		<feedburner:origLink>http://www.sqlrepl.com/sql-server/creating-mergereplication-conflict-alerts/</feedburner:origLink></item>
		<item>
		<title>Error when creating a subscription</title>
		<link>http://feedproxy.google.com/~r/sqlrepl/~3/nlTyIPVlRok/</link>
		<comments>http://www.sqlrepl.com/sql-server/error-when-creating-a-subscription/#comments</comments>
		<pubDate>Tue, 17 Jan 2012 04:44:17 +0000</pubDate>
		<dc:creator>Brandon Williams</dc:creator>
				<category><![CDATA[Merge]]></category>
		<category><![CDATA[Peer to Peer]]></category>
		<category><![CDATA[Replication]]></category>
		<category><![CDATA[Snapshot]]></category>
		<category><![CDATA[SQL Server]]></category>
		<category><![CDATA[SQLServerPedia Syndication]]></category>
		<category><![CDATA[Transactional]]></category>
		<category><![CDATA[Troubleshoot]]></category>
		<category><![CDATA[error]]></category>
		<category><![CDATA[implement]]></category>
		<category><![CDATA[security]]></category>
		<category><![CDATA[troubleshoot]]></category>

		<guid isPermaLink="false">http://www.sqlrepl.com/?p=1753</guid>
		<description><![CDATA[When creating a subscription in SQL Server sometimes the following error will occur: The remote server "%s" does not exist, or has not been designated as a valid Publisher, or you may not have permission to see available Publishers. The error is pretty straightforward and indicates that the replication agent login used to connect to [...]]]></description>
				<content:encoded><![CDATA[<p>When creating a subscription in SQL Server sometimes the following error will occur:</p>
<p><strong>The remote server "%s" does not exist, or has not been designated as a valid Publisher, or you may not have permission to see available Publishers.</strong></p>
<p>The error is pretty straightforward and indicates that the replication agent login used to connect to the Publisher is not a member of the publication access list (PAL).  That would be the Distribution Agent process account for Transactional Replication and the Merge Agent process account for Merge Replication.  Add the agent process account to the PAL and try to create the subscription again.</p>
<p><a href="http://www.sqlrepl.com/wp-content/uploads/2012/01/PublicationAccessList.png"><img class="aligncenter size-full wp-image-1756" title="Publication Access List" src="http://www.sqlrepl.com/wp-content/uploads/2012/01/PublicationAccessList.png" alt="Publication Access List" width="704" height="631" /></a></p>
<div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/sqlrepl?a=nlTyIPVlRok:2jW_hHVH70g:3QFJfmc7Om4"><img src="http://feeds.feedburner.com/~ff/sqlrepl?i=nlTyIPVlRok:2jW_hHVH70g:3QFJfmc7Om4" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/sqlrepl?a=nlTyIPVlRok:2jW_hHVH70g:dnMXMwOfBR0"><img src="http://feeds.feedburner.com/~ff/sqlrepl?d=dnMXMwOfBR0" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/sqlrepl?a=nlTyIPVlRok:2jW_hHVH70g:F7zBnMyn0Lo"><img src="http://feeds.feedburner.com/~ff/sqlrepl?i=nlTyIPVlRok:2jW_hHVH70g:F7zBnMyn0Lo" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/sqlrepl?a=nlTyIPVlRok:2jW_hHVH70g:V_sGLiPBpWU"><img src="http://feeds.feedburner.com/~ff/sqlrepl?i=nlTyIPVlRok:2jW_hHVH70g:V_sGLiPBpWU" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/sqlrepl?a=nlTyIPVlRok:2jW_hHVH70g:gIN9vFwOqvQ"><img src="http://feeds.feedburner.com/~ff/sqlrepl?i=nlTyIPVlRok:2jW_hHVH70g:gIN9vFwOqvQ" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/sqlrepl?a=nlTyIPVlRok:2jW_hHVH70g:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/sqlrepl?d=yIl2AUoC8zA" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/sqlrepl/~4/nlTyIPVlRok" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.sqlrepl.com/sql-server/error-when-creating-a-subscription/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://www.sqlrepl.com/sql-server/error-when-creating-a-subscription/</feedburner:origLink></item>
	</channel>
</rss>
