<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	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/"
	>

<channel>
	<title>AlwaysOn &#8211; Prologika</title>
	<atom:link href="https://prologika.com/tag/alwayson/feed/" rel="self" type="application/rss+xml" />
	<link>https://prologika.com</link>
	<description>Business Intelligence Consulting and Training in Atlanta</description>
	<lastBuildDate>Wed, 28 Jun 2017 12:49:16 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=7.0</generator>
	<item>
		<title>Running ETL on AlwaysOn Primary Replica</title>
		<link>https://prologika.com/running-etl-on-alwayson-primary-replica/</link>
					<comments>https://prologika.com/running-etl-on-alwayson-primary-replica/#respond</comments>
		
		<dc:creator><![CDATA[Prologika - Teo Lachev]]></dc:creator>
		<pubDate>Wed, 28 Jun 2017 12:49:16 +0000</pubDate>
				<category><![CDATA[Blog]]></category>
		<category><![CDATA[AlwaysOn]]></category>
		<category><![CDATA[ETL]]></category>
		<category><![CDATA[SSIS]]></category>
		<guid isPermaLink="false">https://prologika.com/?p=5029</guid>

					<description><![CDATA[Scenario: Consider a SQL Server configured for AlwaysOn Availability Groups where a set of databases can fail over to another node. You have SSIS jobs and you created them on [&#8230;]]]></description>
										<content:encoded><![CDATA[<p><strong>Scenario</strong>: Consider a SQL Server configured for AlwaysOn Availability Groups where a set of databases can fail over to another node. You have SSIS jobs and you created them on both nodes. However, you need to check if the current node on which the job is running is the primary node. If you don&#8217;t do this, the job fails because the database isn&#8217;t accessible.</p>
<p><strong>Solution</strong>: In every SQL Server Agent Job, add a first step to check if one of the replicated databases in the AlwaysOn availability group is the primary replica:</p>
<p><span style="color: blue; font-family: Consolas; font-size: 9pt;">IF<span style="color: black;"><br />
<span style="color: lime;">sys<span style="color: gray;">.<span style="color: black;">fn_hadr_is_primary_replica<span style="color: blue;"><br />
<span style="color: gray;">(<span style="color: red;">&#8216;&lt;replicated dataset name here&gt;&#8217;<span style="color: gray;">)<span style="color: black;"><br />
<span style="color: gray;">=<span style="color: black;"> 0<br />
</span></span></span></span></span></span></span></span></span></span></span></span></p>
<p><span style="color: blue; font-family: Consolas; font-size: 9pt;">BEGIN<span style="color: black;"><br />
</span></span></p>
<p><span style="color: black; font-family: Consolas; font-size: 9pt;"><br />
<span style="color: blue;">EXEC<span style="color: black;"> msdb<span style="color: gray;">..<span style="color: maroon;">sp_stop_job<span style="color: blue;"><br />
<span style="color: red;">N&#8217;DW Daily Load&#8217;<span style="color: gray;">;<span style="color: black;"><br />
</span></span></span></span></span></span></span></span></span></p>
<p><span style="color: blue; font-family: Consolas; font-size: 9pt;">END<br />
</span></p>
<p>This script checks if the database is a primary replica. If this is not the case, the script stops the next step, which in this case is the &#8220;DW Daily Load&#8221; step.</p>
<p><img decoding="async" src="https://prologika.com/wp-content/uploads/2017/06/062817_1247_RunningETLo1.png" alt="" /></p>
]]></content:encoded>
					
					<wfw:commentRss>https://prologika.com/running-etl-on-alwayson-primary-replica/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
	</channel>
</rss>
