<?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>SQL Diablo</title>
	
	<link>http://www.sqldiablo.com</link>
	<description>Ramblings of a (not so) evil Accidental DBA</description>
	<lastBuildDate>Tue, 14 May 2013 17:39:03 +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>
		<atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="self" type="application/rss+xml" href="http://feeds.feedburner.com/SqlDiablo" /><feedburner:info uri="sqldiablo" /><atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="hub" href="http://pubsubhubbub.appspot.com/" /><item>
		<title>Introduction to SQL Server 2012 AlwaysOn Availability Groups – Q &amp; A</title>
		<link>http://feedproxy.google.com/~r/SqlDiablo/~3/TLklAyIEqLY/</link>
		<comments>http://www.sqldiablo.com/2013/05/13/introduction-to-sql-server-2012-alwayson-availability-groups-q-a/#comments</comments>
		<pubDate>Mon, 13 May 2013 15:20:35 +0000</pubDate>
		<dc:creator>SQL Diablo</dc:creator>
				<category><![CDATA[AlwaysOn]]></category>
		<category><![CDATA[Database Administration]]></category>
		<category><![CDATA[Events]]></category>
		<category><![CDATA[SQL Server]]></category>
		<category><![CDATA[SQL Server 2012]]></category>
		<category><![CDATA[Availability Groups]]></category>
		<category><![CDATA[DBA]]></category>
		<category><![CDATA[Disaster Recovery]]></category>
		<category><![CDATA[High Availability]]></category>
		<category><![CDATA[PASS]]></category>
		<category><![CDATA[SQL]]></category>

		<guid isPermaLink="false">http://www.sqldiablo.com/?p=445</guid>
		<description><![CDATA[Last week, I presented my session &#8220;Introduction to SQL Server 2012 AlwaysOn Availability Groups&#8221; to my largest audience ever at the PASS DBA Fundamentals Virtual Chapter. There were 191 total attendees, and I would like to take a moment to &#8230; <a href="http://www.sqldiablo.com/2013/05/13/introduction-to-sql-server-2012-alwayson-availability-groups-q-a/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
				<content:encoded><![CDATA[<p>Last week, I presented my session &#8220;<a title="AlwaysOn Availability Groups" href="http://www.sqldiablo.com/alwayson/" target="_blank">Introduction to SQL Server 2012 AlwaysOn Availability Groups</a>&#8221; to my largest audience ever at the <a title="PASS DBA Fundamentals Virtual Chapter" href="http://fundamentals.sqlpass.org" target="_blank">PASS DBA Fundamentals Virtual Chapter</a>. There were 191 total attendees, and I would like to take a moment to thank all of you for attending, it was truly AWESOME! Also, I would like to take a moment to apologize for the audio issues that occurred throughout the session. This was primarily my fault, as I had joined the webinar twice, once as a presenter by phone with a high-quality headset and good quality audio connection, and another time as an attendee just to keep an eye on what all of you were seeing. Unfortunately, the attendee laptop was somehow selected as the microphone to be used while I presented from my actual presenter laptop, and that is why the audio kept fading in and out and was poor quality. Mark, Mike, and I met to discuss this and how to prevent it in the future, and so this should not happen again.</p>
<p>Anyway, I received several questions during this session that I wanted to address via this blog post, as I think they could benefit everyone. So without further delay, here they are:</p>
<ul>
<li>What would you recommend for the maximum number of (practical) databases per Availability Group?
<ul>
<li>This will depend on the hardware you’re running on (specifically the number of CPU threads that the primary replica can support), and the network bandwidth available between your primary and secondary replicas. Also, the amount of transactions per second occurring in each database will be a factor in this. There are no hard-and-fast rules about how many databases can be in the Availability Group. Please see <a href="http://msdn.microsoft.com/en-us/library/ff878487.aspx#RestrictionsAG" target="_blank">http://msdn.microsoft.com/en-us/library/ff878487.aspx#RestrictionsAG </a>for Microsoft&#8217;s recommendations in this regard.</li>
</ul>
</li>
<li>How do Availability Groups work with CDC?
<ul>
<li>CDC is fully supported (and even complimented by) AlwaysOn Availability Groups. Please see this MSDN article: <a href="http://msdn.microsoft.com/en-us/library/hh403414.aspx#CDC" target="_blank">http://msdn.microsoft.com/en-us/library/hh403414.aspx#CDC</a></li>
</ul>
</li>
<li>If an Availability Group is setup at the SQL Instance level, can you have multiple SQL instances per cluster node and have an Active-Active configuration?
<ul>
<li>First of all, an Availability Groups is not the same as a Failover Cluster Instance. An Availability Group is a group of 1 or more databases that all failover together and share a set of replicas onto which that failover may occur. Each replica is another SQL Server instance that sits on another node of the same Windows Server Failover Cluster that the primary replica does. With that said, an Availability Group can only have replicas that are nodes of the same Windows Server Failover Cluster. Therefore, active/active in an Availability Group would be more a question about which replicas are readable or not and not so much about running multiple Availability Groups. Additionally, an Availability Group is not an instance-level failover (like in a Failover Cluster Instance), so things like the master and MSDB databases, logins, etc. do not failover in an Availability Group. You can have multiple Availability Groups running at the same time, but keep in mind that they would all need to be sitting on nodes of the same Windows Server Failover Cluster, and only one instance of SQL Server per cluster node can participate in Availability Groups due to the coordination between the Availability Groups and their underlying Windows Server Failover Cluster. To clarify that a bit, you cannot install 2 SQL Server instances to the same Windows Server Failover Cluster node and have one instance host a replica for on Availability Group and the other instance host a replica for a different Availability Group. Instead, you would have a single SQL Server Instance on the Windows Server Failover Cluster node that would participate in both of the Availability Groups.</li>
</ul>
</li>
<li>Is it possible to set this up with demo licenses? Is there a temp/demo/developer clustering license available from Microsoft? (for those of us on the bench who would like to test this)
<ul>
<li>Absolutely! Microsoft offers an evaluation version of SQL Server 2012, which can be downloaded from <a href="http://www.microsoft.com/en-us/download/details.aspx?id=29066" target="_blank">http://www.microsoft.com/en-us/download/details.aspx?id=29066</a> and used to test AlwaysOn Availability Groups. In addition, if you already have SQL Server Developer Edition licenses, you can use those licenses to test AlwaysOn Availability Groups (you just can’t use them in any production capacity).</li>
</ul>
</li>
<li>Can you select which databases are in the Availability Group? Can you have two different databases from two different servers?
<ul>
<li>Yes, you can select which databases are part of the Availability Group. However, any database that is part of the Availability Group will need to be present on the primary replica and then synchronized to all secondary replicas. Therefore, if your primary replica has 10 databases, you could select 5 of those databases to be part of the Availability Group and those would then be synchronized to the other replicas. The 5 databases not included in the Availability Group would remain untouched and only on the server that they were on originally. The same is true of the secondary replicas. They will already contain all of the databases that are part of the Availability Group, but they can also contain a number of local databases that are not part of the Availability Group.</li>
</ul>
</li>
<li>Can we use SQL Server Standard edition for only two nodes? (reference: <a href="http://msdn.microsoft.com/en-us/library/cc645993.aspx" target="_blank">http://msdn.microsoft.com/en-us/library/cc645993.aspx</a>)
<ul>
<li>No, you cannot. What the High Availability matrix is showing is running a two node Failover Cluster Instance on Standard edition. There are only two editions of SQL Server that will support Availability Groups, and those are Enterprise and Developer editions, and both edition support up to 5 replicas in an Availability Group. Remember that AlwaysOn is just a marketing term that Microsoft uses to describe several of their High Availability features, and is not a feature in itself. Don’t let their overuse of this term confuse you.</li>
</ul>
</li>
<li>Should the listener be a separate server? Does the listener need to have SQL Server installed on it?
<ul>
<li>The listener name is just a cluster resource name, and is not a separate physical server or cluster node, nor is it a separate SQL Server instance like a Database Mirroring Witness would be. Think of the listener name as just another service that the Windows Server Failover Cluster can host on any of its nodes. The caveat here is that the Availability Group and the Cluster are talking to one another and so the Availability Group makes sure that the listener name is always hosted by the cluster node that is the primary replica of the Availability Group. Therefore it is safe to say that the primary replica (a stand-alone SQL Server Instance installed on a Windows Server Failover Cluster node) is always the host of the listener name (if you created one).</li>
</ul>
</li>
</ul>
<div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/SqlDiablo?a=TLklAyIEqLY:JKy0VkPe_CQ:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/SqlDiablo?d=yIl2AUoC8zA" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/SqlDiablo/~4/TLklAyIEqLY" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.sqldiablo.com/2013/05/13/introduction-to-sql-server-2012-alwayson-availability-groups-q-a/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://www.sqldiablo.com/2013/05/13/introduction-to-sql-server-2012-alwayson-availability-groups-q-a/?utm_source=rss&amp;utm_medium=rss&amp;utm_campaign=introduction-to-sql-server-2012-alwayson-availability-groups-q-a</feedburner:origLink></item>
		<item>
		<title>Service Broker Replication – Using AlwaysOn Availability Groups with Service Broker Replication</title>
		<link>http://feedproxy.google.com/~r/SqlDiablo/~3/5vnFSE4a6JQ/</link>
		<comments>http://www.sqldiablo.com/2013/04/30/service-broker-replication-using-alwayson-availability-groups-with-service-broker-replication/#comments</comments>
		<pubDate>Tue, 30 Apr 2013 15:00:50 +0000</pubDate>
		<dc:creator>SQL Diablo</dc:creator>
				<category><![CDATA[AlwaysOn]]></category>
		<category><![CDATA[Database Administration]]></category>
		<category><![CDATA[Development]]></category>
		<category><![CDATA[Service Broker]]></category>
		<category><![CDATA[SQL Server]]></category>
		<category><![CDATA[SQL Server 2012]]></category>
		<category><![CDATA[Disaster Recovery]]></category>
		<category><![CDATA[High Availability]]></category>
		<category><![CDATA[Projects]]></category>
		<category><![CDATA[Replication]]></category>
		<category><![CDATA[SQL]]></category>

		<guid isPermaLink="false">http://www.sqldiablo.com/?p=377</guid>
		<description><![CDATA[Service Broker Replication &#8211; Table of Contents Using AlwaysOn Availability Groups with Service Broker Replication Well, it has certainly been a while since the last installment of this blog series, and now I&#8217;m working at a new company and doing &#8230; <a href="http://www.sqldiablo.com/2013/04/30/service-broker-replication-using-alwayson-availability-groups-with-service-broker-replication/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
				<content:encoded><![CDATA[<p><a title="Service Broker Replication - Table of Contents" href="http://www.sqldiablo.com/service-broker-replication/"><strong>Service Broker Replication &#8211; Table of Contents</strong></a></p>
<p><strong><span style="text-decoration: underline;">Using AlwaysOn Availability Groups with Service Broker Replication</span><br />
</strong></p>
<p>Well, it has certainly been a while since the last installment of this blog series, and now I&#8217;m working at a new company and doing a pretty different kind of work. However, I&#8217;ve been getting a lot of requests to complete this series, and I still have the source-code, so let&#8217;s get to it!</p>
<p>When we last left off on our little adventure, I described the general architecture of my Service Broker Replication system and why I made the design decisions that I did. In this blog post, I&#8217;m going to further that discussion a bit by explaining how Service Broker and AlwaysOn Availability Groups can be used together to increase the availability of the system.</p>
<h2>Why is Availability Important to Service Broker Replication?</h2>
<p>Well, other than the obvious answer that availability is important to EVERY system, there is one key part of the Service Broker Replication topology that is especially susceptible to a failure, and where a failure would be devastating: the distributor database. If the distributor database fails, then not only will messages fail to be sent through the environment (and therefore the replication partners would get out of sync, but we would also lose the ability to bring new replication partners online, as we wouldn&#8217;t have the message history needed to bring them up to speed. For these reasons, some kind of availability solution is critical to Service Broker Replication.</p>
<p>In addition to preventing data-loss, we also need to minimize the amount of time that the distributor is unavailable during an outage. This is because the longer the distributor is inaccessible, the more our replication partners will get out of sync, and the more likely we are to have conflicts occur because expected updates aren&#8217;t being replicated across the environment. With that said, we could just implement something like Database Mirroring, Log Shipping, or a Failover Cluster Instance, and all of those are certainly viable options. However, what would happen if there were a loss of connectivity at the data-center housing our distributor database? What if that outage lasted for a couple minutes? How about a couple hours? A couple days? A couple weeks? I think you get the idea. If we implement one of the availability solutions I mentioned above, we don&#8217;t really have an answer to those questions (yes, Log Shipping and geo-clustering can potentially solve the issue, but they each have caveats I&#8217;d like to avoid, like data-loss due to backup timing and prohibitively expensive and complex SAN hardware).</p>
<h2>The Solution</h2>
<p>Enter SQL Server 2012 Enterprise Edition and AlwaysOn Availability Groups. Chances are, if you&#8217;re at an organization that needs a solution like Service Broker Replication, then you&#8217;re probably already running Enterprise Edition. If not, you may want to consider increasing my licensing budget a bit, because Enterprise Edition has some pretty amazing features! One of those amazing features is AlwaysOn Availability Groups, which take the best features of Database Mirroring and Failover Cluster Instances and combine them together. For more information on AlwaysOn Availability Groups and why they solve a lot of availability problems, check out my <a title="AlwaysOn Availability Groups" href="http://www.sqldiablo.com/alwayson/">AlwaysOn Availability Groups</a> page.</p>
<p>The reason why AlwaysOn Availability Groups are a big win for Service Broker Replication is that unlike Failover Cluster Instances, Availability Groups don&#8217;t require any cluster shared storage objects. Therefore, geo-clustering with AlwaysOn Availability Groups gets MUCH easier (and cheaper) than it is in a Failover Cluster Instance. So, if you have an Availability Group that spans two data-centers, and the first data-center&#8217;s Internet connection fails, your Availability Group will automatically failover to the node in the working data-center, and your Service Broker Replication topology will remain up and running, with no data-loss (actually, there is a possibility for data-loss if you&#8217;re running in asynchronous commit mode, but it&#8217;s usually pretty minimal).</p>
<p>Another beautiful thing about this combination is that even if messages do fail to send to the distributor or from the distributor to a replication partner during the failover process, those messages will remain en-queued by Service Broker and will be resent once connectivity is restored, which is usually within a minute or two. Therefore, as long as we don&#8217;t have any data-loss at the distributor database, our replication partners will synchronize as though no failure even happened.</p>
<p>In addition to making the distributor database a member of an Availability Group, you can also reap the benefits of Availability Groups at each of your replication partners, and keep your local databases and applications up and running in the event of patching, hardware failures, and losses of connectivity. However, I would consider running Availability Groups at the replication partners a lower priority than running an Availability Group at the distributor, so if cash is short, at least make sure your distributor is protected.</p>
<h2>Coming Up</h2>
<p>Stay tuned! This series gets a lot more juicy in the next installment, as I dive into the different message types that Service Broker Replication sends and how they each work. This is where we make the leap from theoretical to practical, so you won&#8217;t want to miss it!</p>
<p><a title="Service Broker Replication - Table of Contents" href="http://www.sqldiablo.com/service-broker-replication/"><strong>Service Broker Replication &#8211; Table of Contents</strong></a></p>
<div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/SqlDiablo?a=5vnFSE4a6JQ:6tC9hlaS0OM:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/SqlDiablo?d=yIl2AUoC8zA" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/SqlDiablo/~4/5vnFSE4a6JQ" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.sqldiablo.com/2013/04/30/service-broker-replication-using-alwayson-availability-groups-with-service-broker-replication/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://www.sqldiablo.com/2013/04/30/service-broker-replication-using-alwayson-availability-groups-with-service-broker-replication/?utm_source=rss&amp;utm_medium=rss&amp;utm_campaign=service-broker-replication-using-alwayson-availability-groups-with-service-broker-replication</feedburner:origLink></item>
		<item>
		<title>Slacking Off…or…Adjusting To Change</title>
		<link>http://feedproxy.google.com/~r/SqlDiablo/~3/aAcHaW3Rhy4/</link>
		<comments>http://www.sqldiablo.com/2013/04/09/slacking-off-or-adjusting-to-change/#comments</comments>
		<pubDate>Tue, 09 Apr 2013 17:22:53 +0000</pubDate>
		<dc:creator>SQL Diablo</dc:creator>
				<category><![CDATA[Career]]></category>
		<category><![CDATA[background]]></category>
		<category><![CDATA[career]]></category>
		<category><![CDATA[Community]]></category>
		<category><![CDATA[Events]]></category>
		<category><![CDATA[personal]]></category>
		<category><![CDATA[Presenting]]></category>
		<category><![CDATA[Speaking]]></category>
		<category><![CDATA[story]]></category>

		<guid isPermaLink="false">http://www.sqldiablo.com/?p=424</guid>
		<description><![CDATA[If you&#8217;re reading this, then I owe you some credit as a committed follower of my blog. In addition to some credit, I also owe you an apology. As you may or may not know, I started a new job &#8230; <a href="http://www.sqldiablo.com/2013/04/09/slacking-off-or-adjusting-to-change/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
				<content:encoded><![CDATA[<p>If you&#8217;re reading this, then I owe you some credit as a committed follower of my blog. <img src='http://i1.wp.com/www.sqldiablo.com/wp-includes/images/smilies/icon_smile.gif?w=584' alt=':-)' class='wp-smiley' data-recalc-dims="1" />  In addition to some credit, I also owe you an apology. As you may or may not know, I started a new job back in November, and since that time I&#8217;ve been slacking off on my blog posts and speaking engagements. For that, I am truly sorry. However, I do have some good news: Now that I&#8217;ve had over 4 months to adjust to these changes, I&#8217;ve finally decided to get off of my lazy butt and start blogging and presenting again!</p>
<p>With that said, here are my plans (for better or for worse):</p>
<ul>
<li>Begin blogging again
<ul>
<li>I&#8217;d like to set my cadence at one blog post every other week or so, until I see how that works out, and then I&#8217;ll adjust it.</li>
<li>I&#8217;d like to complete my Service Broker Replication series (because I should, and also because I&#8217;ve been asked to by a couple of readers).</li>
<li>In my new position, I am doing quite a bit of documentation and written communication, and blogging can only help me improve in those areas.</li>
</ul>
</li>
<li>Start speaking again
<ul>
<li>I have to say, I&#8217;ve missed the limelight. <img src='http://i1.wp.com/www.sqldiablo.com/wp-includes/images/smilies/icon_wink.gif?w=584' alt=';-)' class='wp-smiley' data-recalc-dims="1" />  But more importantly, I&#8217;ve missed being able to help other SQL Server Professionals, and I miss my SQL Family as well.</li>
<li>I&#8217;d like to start developing new sessions again. I have a couple of ideas for topics that I&#8217;d like to learn more about, and I think they would make great presentations as well (I&#8217;ll probably be blogging about them too).</li>
<li>I&#8217;ve gained so much from being a member of PASS, that I need to keep giving back to the community in return. After all, that&#8217;s how this sort of community works. <img src='http://i1.wp.com/www.sqldiablo.com/wp-includes/images/smilies/icon_smile.gif?w=584' alt=':-)' class='wp-smiley' data-recalc-dims="1" /> </li>
</ul>
</li>
</ul>
<p>So in conclusion, I&#8217;m back, I&#8217;m recharged, I&#8217;m excited, and I think you&#8217;ll be reading, hearing, and seeing a whole lot more of me as we head into summer. It&#8217;s going to be a great year!</p>
<div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/SqlDiablo?a=aAcHaW3Rhy4:gBzXQcXCZug:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/SqlDiablo?d=yIl2AUoC8zA" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/SqlDiablo/~4/aAcHaW3Rhy4" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.sqldiablo.com/2013/04/09/slacking-off-or-adjusting-to-change/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://www.sqldiablo.com/2013/04/09/slacking-off-or-adjusting-to-change/?utm_source=rss&amp;utm_medium=rss&amp;utm_campaign=slacking-off-or-adjusting-to-change</feedburner:origLink></item>
		<item>
		<title>Creating a Login with a SID</title>
		<link>http://feedproxy.google.com/~r/SqlDiablo/~3/Um37lH08QzQ/</link>
		<comments>http://www.sqldiablo.com/2012/09/17/creating-a-login-with-a-sid/#comments</comments>
		<pubDate>Mon, 17 Sep 2012 15:00:21 +0000</pubDate>
		<dc:creator>SQL Diablo</dc:creator>
				<category><![CDATA[AlwaysOn]]></category>
		<category><![CDATA[Database Administration]]></category>
		<category><![CDATA[SQL Server 2005]]></category>
		<category><![CDATA[SQL Server 2008]]></category>
		<category><![CDATA[SQL Server 2012]]></category>

		<guid isPermaLink="false">http://www.sqldiablo.com/?p=387</guid>
		<description><![CDATA[For those of you who don&#8217;t already know, there is a new PASS Virtual Chapter called DBA Fundamentals that has meetings on the first Tuesday of every month. The chapter specializes in providing training and support for new DBAs and &#8230; <a href="http://www.sqldiablo.com/2012/09/17/creating-a-login-with-a-sid/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
				<content:encoded><![CDATA[<p>For those of you who don&#8217;t already know, there is a new PASS Virtual Chapter called <a title="DBA Fundamentals" href="http://fundamentals.sqlpass.org/" target="_blank">DBA Fundamentals</a> that has meetings on the first Tuesday of every month. The chapter specializes in providing training and support for new DBAs and also for seasoned DBAs who would just like to brush-up on their skills. I was fortunate enough to be asked to present at their second meeting on 9/4, and I gave my session about <a title="Service Broker" href="http://www.sqldiablo.com/service-broker/" target="_blank">SQL Server Service Broker</a>. One of the questions that I was asked during the session was: <strong>How do you create a login with a SID, and more specifically, how do you create and find the SID for that login?</strong></p>
<p>In my session on Service Broker and also in my session on AlwaysOn Availability Groups, I mention that if you&#8217;re using AlwaysOn Availability Groups or Database Mirroring that you should create your logins with the same SID on each instance/replica so that when a failover occurs, you don&#8217;t have to re-map your database users to their appropriate logins. However, I don&#8217;t really go into the detail of how to do that in my sessions, so I wanted to take some time to do that here.</p>
<pre>use master;

-- Get a new GUID value to use as the SID
declare @SID uniqueidentifier = newid();

-- In order to use the SID in a create login statement, it must be in binary format
declare @SID_Binary varbinary(max) = (select cast(@SID as varbinary(max)));

-- View the SID in GUID and Binary format:
select @SID, @SID_Binary;
-- E72669E3-9FAA-4BCB-8F8F-570EBF114674, 0xE36926E7AA9FCB4B8F8F570EBF114674

-- Here is the statement we really want to run:
--create login SQLDiablo with password='Passw0rd!', sid=0xE36926E7AA9FCB4B8F8F570EBF114674;

-- But that requires us to paste in the SID. There has to be a better way:
declare @UserName nvarchar(128) = 'SQLDiablo', @Password nvarchar(max) = 'Passw0rd!';
declare @Query nvarchar(max) = 'create login ' + @UserName + ' with password=''' + @Password + ''', sid=0x' + cast('' as xml).value('xs:hexBinary(sql:variable("@SID_Binary") )', 'varchar(max)') + ';';

select @Query;
execute sp_executesql @Query;

-- Since varbinary can be a little tricky to work with in dynamic SQL, XPath is our friend.
-- Above we converted the value of @SID_Binary to Hex using XPath's value method (don't forget to add 0x to the beginning of it).

-- Get the SID for the login we just created, as a GUID
select sp.name, cast(sp.sid as uniqueidentifier) SID_AS_GUID from sys.server_principals sp where sp.name = 'SQLDiablo';

-- SQLDiablo, E72669E3-9FAA-4BCB-8F8F-570EBF114674

set @Query = 'drop login ' + @UserName + ';';
execute sp_executesql @Query;</pre>
<div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/SqlDiablo?a=Um37lH08QzQ:ZeJ953l9QzM:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/SqlDiablo?d=yIl2AUoC8zA" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/SqlDiablo/~4/Um37lH08QzQ" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.sqldiablo.com/2012/09/17/creating-a-login-with-a-sid/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://www.sqldiablo.com/2012/09/17/creating-a-login-with-a-sid/?utm_source=rss&amp;utm_medium=rss&amp;utm_campaign=creating-a-login-with-a-sid</feedburner:origLink></item>
		<item>
		<title>SQL Saturday #164 – Cleveland: Lessons Learned</title>
		<link>http://feedproxy.google.com/~r/SqlDiablo/~3/KRJfrEggJs4/</link>
		<comments>http://www.sqldiablo.com/2012/08/20/sql-saturday-164-cleveland-lessons-learned/#comments</comments>
		<pubDate>Mon, 20 Aug 2012 19:30:10 +0000</pubDate>
		<dc:creator>SQL Diablo</dc:creator>
				<category><![CDATA[Events]]></category>
		<category><![CDATA[SQL Saturday]]></category>
		<category><![CDATA[Lessons Learned]]></category>
		<category><![CDATA[Networking]]></category>
		<category><![CDATA[Wrap-Up]]></category>

		<guid isPermaLink="false">http://www.sqldiablo.com/?p=370</guid>
		<description><![CDATA[Well, SQL Saturday #164 &#8211; Cleveland 2012 is in the history books, and it looks like all of our planning, blood, sweat, and tears have paid off. This was my first time helping organize a SQL Saturday, and I&#8217;ve got &#8230; <a href="http://www.sqldiablo.com/2012/08/20/sql-saturday-164-cleveland-lessons-learned/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
				<content:encoded><![CDATA[<p>Well, SQL Saturday #164 &#8211; Cleveland 2012 is in the history books, and it looks like all of our planning, blood, sweat, and tears have paid off. This was my first time helping organize a SQL Saturday, and I&#8217;ve got to say it was quite an experience! As part of the core planning team and as the lead for the restaurant and catering team, my last several months have been filled with tons of planning meetings, e-mails, phone calls, and lots and lots of little details to manage. It&#8217;s amazing how much work goes into an event like this, and <strong>it&#8217;s even more amazing to see a great team come together and pull it off</strong>. Before I continue with my lessons learned, I just wanted to take a moment to thank the awesome people who really helped make this event a success:</p>
<ul>
<li>Craig Purnell &amp; Allen White &#8211; Thanks for being such awesome leaders and mentors throughout the planning process, I really appreciated your council and direction</li>
<li>The Devry staff &#8211; <strong>THANK YOU, THANK YOU, THANK YOU</strong> for donating your facility for the day, for helping me remember to take breaks every now and then, for helping keep me sane, and for all of your help throughout the day (<strong>you guys were truly AWESOME!!!</strong>)</li>
<li>The Mavis Winkle&#8217;s staff &#8211; Despite rushed deadlines, miscommunications, double-bookings, an overly stressed team lead (yours truly), and lots of calls back and forth, you guys still pulled off two awesome meals for us and helped make for a great event. I would especially like to thank the owners, Bob and Marie, for helping to make my life a little less stressful on Friday and Saturday. It was really cool getting to work with you and your staff.</li>
<li>All of our sponsors &#8211; <strong>We couldn&#8217;t do an event like this without your support, and for that we are EXTREMELY grateful. THANK YOU!</strong></li>
<li>Steven Wright and SQL Sentry &#8211; Thanks for sponsoring our Speaker/Sponsor/Volunteer dinner, <strong>YOU ROCK!</strong></li>
<li>Ann Marie Kozlowski &#8211; Thanks for letting us use the Solutient offices for bag stuffing, and thanks for taking care of the breakfast arrangements</li>
<li>Carlton Ramsey &amp; Cory Stevenson (and his wife) &#8211; Thanks for buying cookies, pop, and all of the other little odds-and-ends that we needed for the event</li>
<li>Sam Nasr &#8211; Thank you for taking care of the after party arrangements</li>
<li>Colleen Morrow, Erin Stellato, and anyone else who helped out &#8211; <strong>THANK YOU SO MUCH!</strong></li>
</ul>
<p>From the speaker&#8217;s dinner on Friday night until I left Devry sometime around 6 PM on Saturday, I was pretty much a blur of activity as I tried to help make sure everything ran smoothly. Despite all of that running around, I was still able to attend two awesome sessions, present my own session, mingle, network, and have a ton of fun! I think the key to my success was that I had an absolutely awesome team that I could rely on to really get things done.</p>
<p>One of the things to keep in mind about an event like this is that <strong>it is inevitable that there will be lots of little problems and issues that come up throughout the day</strong>. The key to handling these issues is to <strong>keep calm, ask for help when you need it, and to trust your team to do their job</strong>. It&#8217;s not necessary to manage every little detail of an event like this. It&#8217;s simply too much to handle for one person. Instead, break the responsibilities up into smaller tasks, assign those tasks to people or teams to accomplish, and then give them the room to do their job.</p>
<p>As far as the food was concerned, there are a couple things to consider when planning an event like this:</p>
<ul>
<li>If you have the space to allow everyone to dine in the same area, then you have a lot more flexibility as to what kinds of food you can serve, and you can even have a fully catered buffet (much like the awesome buffet at SQL Saturday in Chicago earlier this year).</li>
<li>If you don&#8217;t have a large common area, then you will need to distribute the food and have the attendees go into the session rooms to eat it. If this is the case, you&#8217;re going to want to go with highly portable food such as boxed lunches.</li>
<li>Don&#8217;t forget to get lots of heavy-duty construction garbage bags and to distribute them throughout the venue to handle the trash that will be generated. It would also be a good idea to have a team that checks the garbage cans and bags throughout the day and empties them as needed.</li>
<li>An afternoon snack is a good idea, but don&#8217;t over do it. We bought 2 cookies for every attendee as an afternoon snack, and we had about half of them left over after the event.</li>
<li>You&#8217;re going to have food left over after an event like this. It might be a good idea to get in touch with your local foodbank, homeless shelter, or area churches before the event and see if they can use the leftover food. They&#8217;ll thank you for it, and it&#8217;s one more way you can give back to the community.</li>
</ul>
<p>As far as the venue goes, here are my thoughts:</p>
<ul>
<li>Keep the logistics of an event like this in mind when choosing a venue. Make sure the hallways are wide enough, the doors won&#8217;t automatically lock you out throughout the day (yep, this actually happened to us), and that there is enough space for the number of attendees you&#8217;re aiming for. Sometimes cheaper (free) isn&#8217;t always better.</li>
<li>Regardless of whether you get the venue for free or at full price, make sure to clean up after your event and to try to help the venue&#8217;s staff in any way you can. After all, you&#8217;re representing PASS as a whole, and you might even want to have another SQL Saturday there next year.</li>
<li>If you&#8217;re having the event at a college or school, why not do a track of sessions that students from the school can attend? It&#8217;s a way of saying thank you for the use of the venue and it&#8217;s also a way to give back to the community. SQL Saturday in Cleveland was able to use the Devry campus here for free as a direct result of SQL Saturday in Chicago doing exactly what I mentioned. The Cleveland team also did a track of intro sessions for the Devry students, and the track was very well received.</li>
</ul>
<p>Other than that, my only advice is to <strong>HAVE FUN</strong>! Events like this aren&#8217;t worth the effort if they&#8217;re not only educational, but fun and social as well. You&#8217;re going to have to work hard to get the job done, but that doesn&#8217;t mean you can&#8217;t play hard too.</p>
<div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/SqlDiablo?a=KRJfrEggJs4:ue7-5PgDZZQ:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/SqlDiablo?d=yIl2AUoC8zA" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/SqlDiablo/~4/KRJfrEggJs4" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.sqldiablo.com/2012/08/20/sql-saturday-164-cleveland-lessons-learned/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://www.sqldiablo.com/2012/08/20/sql-saturday-164-cleveland-lessons-learned/?utm_source=rss&amp;utm_medium=rss&amp;utm_campaign=sql-saturday-164-cleveland-lessons-learned</feedburner:origLink></item>
		<item>
		<title>AlwaysOn Availability Groups, Isolation Levels, &amp; Selects Blocking the Redo Thread</title>
		<link>http://feedproxy.google.com/~r/SqlDiablo/~3/KpmY8GKq-CQ/</link>
		<comments>http://www.sqldiablo.com/2012/08/01/alwayson-availability-groups-isolation-levels-selects-blocking-writers/#comments</comments>
		<pubDate>Wed, 01 Aug 2012 15:30:34 +0000</pubDate>
		<dc:creator>SQL Diablo</dc:creator>
				<category><![CDATA[AlwaysOn]]></category>
		<category><![CDATA[Database Administration]]></category>
		<category><![CDATA[Development]]></category>
		<category><![CDATA[SQL Server]]></category>
		<category><![CDATA[SQL Server 2012]]></category>
		<category><![CDATA[Availability Groups]]></category>
		<category><![CDATA[Blocking]]></category>
		<category><![CDATA[Isolation Levels]]></category>

		<guid isPermaLink="false">http://www.sqldiablo.com/?p=344</guid>
		<description><![CDATA[This past weekend, I had the pleasure of presenting my session SQL Server 2012 AlwaysOn Readable Secondaries at SQL Saturday #126 in Indianapolis, IN. In that session, I covered the basics of AlwaysOn Availability Groups, how to set them up, &#8230; <a href="http://www.sqldiablo.com/2012/08/01/alwayson-availability-groups-isolation-levels-selects-blocking-writers/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
				<content:encoded><![CDATA[<p>This past weekend, I had the pleasure of presenting my session <a title="SQL Server 2012 AlwaysOn Readable Secondaries" href="http://www.sqlsaturday.com/viewsession.aspx?sat=126&amp;sessionid=9207" target="_blank">SQL Server 2012 AlwaysOn Readable Secondaries</a> at SQL Saturday #126 in Indianapolis, IN. In that session, I covered the basics of AlwaysOn Availability Groups, how to set them up, failing over, and using readable secondary replicas for read-only workloads and backups. During the session, I always make sure to mention the possibility of queries running on the secondary replica blocking the redo thread that is trying to write changes from the primary database to the secondary database.</p>
<p>After mentioning this caveat, I was asked a very good question: <strong>Can you use transaction isolation levels (such as snapshot isolation) with AlwaysOn Availability Groups, and would they help to avoid the issue of read-only queries on secondary replicas blocking the redo thread?</strong> In order to answer this question, I&#8217;m going to break it two parts, and then we&#8217;ll work through a couple demos to illustrate the answers.</p>
<p><span style="text-decoration: underline;"><strong>Questions:</strong></span></p>
<p><strong>Q: </strong>Can you use transaction isolation levels with AlwaysOn Availability Groups?<strong><br />
A: </strong>Yes and no. Yes, you can set whatever isolation level you would like when running queries on the secondary replicas, and SQL Server will not return an error. However, SQL Server will automatically override the isolation level (and ignore all lock hints) when querying a read-only replica, and instead force the queries to use snapshot isolation.</p>
<p>Per the &#8220;Benefits&#8221; topic of the <a title="Active Secondaries: Readable Secondary Replicas (AlwaysOn Availability Groups)" href="http://msdn.microsoft.com/en-us/library/ff878253.aspx#Benefits" target="_blank">Active Secondaries: Readable Secondary Replicas (AlwaysOn Availability Groups)</a> BOL article:</p>
<p style="padding-left: 30px;">Read-only workloads use row versioning to remove blocking contention on the secondary databases. All queries that run against the secondary databases are automatically mapped to snapshot isolation transaction level, even when other transaction isolation levels are explicitly set. Also, all locking hints are ignored. This eliminates reader/writer contention.</p>
<p><strong>Q: </strong>Does using snapshot isolation prevent read-only queries from blocking the redo thread on secondary replicas?<br />
<strong>A:</strong> After reading the above quote from BOL, you would think that read-only queries won&#8217;t block the redo thread, and that is true for DML statements. However, it is not true for DDL statements. Sure, snapshot isolation prevents read-only queries on the secondary replicas from taking locks and preventing other DML statements against the database from executing, but it doesn&#8217;t prevent the read-only queries from taking schema stability locks and blocking DDL statements.</p>
<p>If you take a look later on in the same article I quoted above, you will come to the &#8220;Read-Only Workload Impact&#8221; section under the &#8220;Performance Considerations&#8221; topic:</p>
<p style="padding-left: 30px;">Also, read-only workloads on the secondary replicas can block data definition language (DDL) changes that are applied through log records. Even though the read operations do not take shared locks because of row versioning, these operations take schema stability (Sch-S) locks, which can block redo operations that are applying DDL changes.</p>
<p><span style="text-decoration: underline;"><strong>Demos:</strong></span></p>
<p>In order to have a reference architecture to use for this demo, I&#8217;m going to use the Availability Group that I setup as part of the presentation that I mentioned at the beginning of this article. If you would like to play along at home, you can download the scripts and slide deck for that session <a href="http://www.sqldiablo.com/alwayson/" target="_blank">here</a>. This Availability Group is called DemoAG, and has three replicas, AlwaysOn1 (primary), AlwaysOn2 (secondary), and AlwaysOn3 (secondary). There are two databases participating in the Availability Group: AdventureWorks2012 and AdventureWorksDW2012. I&#8217;m going to be using AdventureWorks2012 for this demo.</p>
<p><span style="text-decoration: underline;">Testing isolation levels and lock hints:</span></p>
<p>Unfortunately, I haven&#8217;t come up with a good way to demonstrate that SQL is overriding the transaction isolation level on the readable secondary because it is actually doing this internally (I&#8217;ll keep looking into this to see if there is a good way to demonstrate it). I can, however, demonstrate that SQL Server is ignoring lock hints on the read-only replicas. I can do this by beginning a transaction, executing a select query with the tablockx lock hint, and leaving the transaction open. I then open a new query window and query sys.dm_tran_locks to see if there is a table lock on the table. If I do this on the primary, you will see an open table lock on the table. If I do this on the secondary, there is no open table lock. If I then try to update data on the primary replica, I am able to see the statement completes and that the data has been written to the replica, even with the open transaction on the secondary that should be holding a table lock.</p>
<pre>-- Execute this in a session of its own on the primary replica:
begin tran;

select * from ErrorLog with (tablockx);

-- With the above transaction open, launch a new query window on
-- the primary replica, and execute this query
-- (you should notice a table lock on the ErrorLog table):
use master;

select
t.name
, dtr.*
from sys.dm_tran_locks dtr
join sys.databases d
on d.name = 'AdventureWorks2012'
and d.database_id = dtr.resource_database_id
join AdventureWorks2012.sys.tables t
on t.object_id = dtr.resource_associated_entity_id;

-- Now try running this insert in the same query window as the sys.dm_tran_locks query
-- (you should get blocked until you commit or rollback the transaction in the other session):
insert AdventureWorks2012.dbo.ErrorLog(UserName, ErrorNumber, ErrorMessage)
values('DemoUser', 1, 'Demo Message');

-- Go ahead and close both query windows, and connect to one of the secondary replicas.
-- Now, try running through the scenario above on the secondary replica (minus the insert).
-- You should notice that there is no table lock being held, even though we explicitly requested one.</pre>
<p><span style="text-decoration: underline;">Testing read-only queries blocking DDL statements:</span></p>
<p>As far as demonstrating that read-only queries can block DDL statements, all we need to do is run a long-running query on the secondary replica and simultaneously try to alter the table that the query on the secondary is using. We should notice that the redo queue size on the secondary then increases and stays that way until we either kill or complete the read-only query. This indicates that the redo thread is not able to commit the DDL changes because the select statement is taking a schema stability lock and preventing the alteration to the table.</p>
<pre>-- Run this query on the secondary replica
-- (it's horribly ugly and inefficient, but the idea is to hold a
-- schema stability lock on ErrorLog for as long as we can):

select
NumbersTable.Number
from AdventureWorks2012.dbo.ErrorLog el
cross apply (
select
Number
from
(
select
row_number() over (order by s1.name) as number
from AdventureWorks2012.sys.sysobjects s1
cross apply AdventureWorks2012.sys.sysobjects s2
cross apply AdventureWorks2012.sys.sysobjects s3
cross apply AdventureWorks2012.sys.sysobjects s4
cross apply AdventureWorks2012.sys.sysobjects s5
) as InnerNumbersTable
) NumbersTable
group by NumbersTable.Number
order by NumbersTable.Number desc;

-- While that beast is running on the secondary replica, run the
-- following on the primary replica:

alter table AdventureWorks2012.dbo.ErrorLog add DemoColumn varchar(10) null;

-- Now go back to the secondary replica, open a new query window, and run the
-- query below (you should notice that the redo queue is greater than 0,
-- which indicates that the redo thread is having trouble applying changes
-- to the database):
select
dhdrs.redo_queue_size
from master.sys.dm_hadr_database_replica_states dhdrs
join master.sys.databases d
on d.database_id = dhdrs.database_id
and d.name = 'AdventureWorks2012';</pre>
<div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/SqlDiablo?a=KpmY8GKq-CQ:cxvDnrzNlLU:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/SqlDiablo?d=yIl2AUoC8zA" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/SqlDiablo/~4/KpmY8GKq-CQ" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.sqldiablo.com/2012/08/01/alwayson-availability-groups-isolation-levels-selects-blocking-writers/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://www.sqldiablo.com/2012/08/01/alwayson-availability-groups-isolation-levels-selects-blocking-writers/?utm_source=rss&amp;utm_medium=rss&amp;utm_campaign=alwayson-availability-groups-isolation-levels-selects-blocking-writers</feedburner:origLink></item>
		<item>
		<title>Getting ready for my first speaking event: SQL Saturday #117 Columbus, OH</title>
		<link>http://feedproxy.google.com/~r/SqlDiablo/~3/DU5ikbys2mA/</link>
		<comments>http://www.sqldiablo.com/2012/06/01/getting-ready-for-my-first-speaking-event-sql-saturday-117-columbus-oh/#comments</comments>
		<pubDate>Fri, 01 Jun 2012 18:05:18 +0000</pubDate>
		<dc:creator>SQL Diablo</dc:creator>
				<category><![CDATA[Career]]></category>
		<category><![CDATA[Community]]></category>
		<category><![CDATA[PASS]]></category>
		<category><![CDATA[Presenting]]></category>
		<category><![CDATA[Speaking]]></category>
		<category><![CDATA[SQL Saturday]]></category>

		<guid isPermaLink="false">http://www.sqldiablo.com/?p=298</guid>
		<description><![CDATA[I&#8217;m sitting in the Panera Bread in Grove City, OH eating lunch, reminiscing about the vacation I just wrapped up in the Hocking Hills, and getting ready for my debut as a technical speaker tomorrow at SQL Saturday #117 in &#8230; <a href="http://www.sqldiablo.com/2012/06/01/getting-ready-for-my-first-speaking-event-sql-saturday-117-columbus-oh/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
				<content:encoded><![CDATA[<p>I&#8217;m sitting in the Panera Bread in Grove City, OH eating lunch, reminiscing about the vacation I just wrapped up in the Hocking Hills, and getting ready for my debut as a technical speaker tomorrow at <a title="SQL Saturday #117" href="http://www.sqlsaturday.com/117/eventhome.aspx" target="_blank">SQL Saturday #117</a> in Columbus. It has taken a lot of patience, perseverance, and hard work to get to this point, and I&#8217;ve had to make a few sacrifices as well (like updating this blog&#8230;sorry about that). The one thing that surprised me the most is the amount of time I&#8217;ve had to invest into getting ready for a single session. I knew that there is a lot of work that goes into making a technical presentation, but I had no idea how time consuming it would be. Building the slide deck was the quick and easy part. After that came building the VMs and getting them just right (and remembering to take snapshots at the right times), building the demo scenarios, scripting and testing the demos, and then the really time consuming part: practicing. Just like in development, it seems like I need to take my time estimates, double them, and then I might be close to almost being right. <img src='http://i1.wp.com/www.sqldiablo.com/wp-includes/images/smilies/icon_wink.gif?w=584' alt=';-)' class='wp-smiley' data-recalc-dims="1" /> </p>
<p>The other tough part in all of this has been juggling life, work, and prepping for my sessions. I&#8217;ve been working on two different sessions and will be presenting each of those sessions twice in a one week period (split between three different speaking engagements: <a title="SQL Saturday #117" href="http://www.sqlsaturday.com/117/eventhome.aspx" target="_blank">SQL Saturday #117</a> in Columbus, the <a title="Ohio North SQL Server User Group" href="http://www.ohionorthsqlserverug.org/" target="_blank">Ohio North SQL Server User Group</a> meeting next Tuesday in Cleveland, and <a title="SQL Saturday #121" href="http://www.sqlsaturday.com/121/eventhome.aspx" target="_blank">SQL Saturday #121</a> in Philadelphia, PA that is a week from tomorrow). Having so much to do in such a short amount of time has been pretty tough to juggle and make sure that nothing slips through the cracks, but somehow I&#8217;ve managed. Don&#8217;t get me wrong, I&#8217;m not complaining about any of this. In fact, I feel extremely honored to have been selected to speak at these events, and it&#8217;s a huge privilege to get to give back to the PASS community that has given me so much over the last year. However, I should have taken more care in submitting my abstracts, scheduling vacations, etc to give myself a little more time to prepare. I think my sessions will go fine, but it never hurts to have a little more time to practice and prepare.</p>
<p>Anyway, I think it&#8217;s time to grab another cup of coffee, sit back, listen to some smooth jazz music, and relax a little before my next batch of craziness kicks in. Take care, and hopefully I&#8217;ll see you at a SQL Saturday, user group meeting, or at the PASS Summit this year. <img src='http://i1.wp.com/www.sqldiablo.com/wp-includes/images/smilies/icon_smile.gif?w=584' alt=':-)' class='wp-smiley' data-recalc-dims="1" /> </p>
<div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/SqlDiablo?a=DU5ikbys2mA:j6pUljZG-6Y:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/SqlDiablo?d=yIl2AUoC8zA" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/SqlDiablo/~4/DU5ikbys2mA" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.sqldiablo.com/2012/06/01/getting-ready-for-my-first-speaking-event-sql-saturday-117-columbus-oh/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		<feedburner:origLink>http://www.sqldiablo.com/2012/06/01/getting-ready-for-my-first-speaking-event-sql-saturday-117-columbus-oh/?utm_source=rss&amp;utm_medium=rss&amp;utm_campaign=getting-ready-for-my-first-speaking-event-sql-saturday-117-columbus-oh</feedburner:origLink></item>
		<item>
		<title>Maintenance Plan Index Rebuild Gotcha</title>
		<link>http://feedproxy.google.com/~r/SqlDiablo/~3/GAcX1geh7R8/</link>
		<comments>http://www.sqldiablo.com/2012/05/08/maintenance-plan-index-rebuild-gotcha/#comments</comments>
		<pubDate>Tue, 08 May 2012 19:57:02 +0000</pubDate>
		<dc:creator>SQL Diablo</dc:creator>
				<category><![CDATA[Database Administration]]></category>
		<category><![CDATA[SQL Server]]></category>
		<category><![CDATA[SQL Server 2008]]></category>
		<category><![CDATA[SQL Server 2012]]></category>
		<category><![CDATA[DBA]]></category>
		<category><![CDATA[Gotcha]]></category>
		<category><![CDATA[Index]]></category>
		<category><![CDATA[Maintenance]]></category>
		<category><![CDATA[Maintenance Plan]]></category>
		<category><![CDATA[Rebuild Index]]></category>

		<guid isPermaLink="false">http://www.sqldiablo.com/?p=281</guid>
		<description><![CDATA[If you&#8217;re anything like me, you probably have a tendency to read what you think is on the page instead of what is actually there. Here&#8217;s a little gotcha that I discovered today when setting up the Rebuild Index task &#8230; <a href="http://www.sqldiablo.com/2012/05/08/maintenance-plan-index-rebuild-gotcha/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
				<content:encoded><![CDATA[<p>If you&#8217;re anything like me, you probably have a tendency to read what you think is on the page instead of what is actually there. Here&#8217;s a little gotcha that I discovered today when setting up the Rebuild Index task in a maintenance plan:</p>
<div id="attachment_282" class="wp-caption alignnone" style="width: 1018px;  border: 1px solid #dddddd; background-color: #f3f3f3; padding-top: 4px; margin: 10px; text-align:center;"><a href="http://i1.wp.com/www.sqldiablo.com/wp-content/uploads/2012/05/MP-Rebuild-Index-Gotcha.jpg" target="_blank"><img class=" wp-image-282 " title="MP Rebuild Index Gotcha" src="http://i1.wp.com/www.sqldiablo.com/wp-content/uploads/2012/05/MP-Rebuild-Index-Gotcha.jpg?resize=584%2C532" alt="" data-recalc-dims="1" /></a><p style=' padding: 0 4px 5px; margin: 0;'  class="wp-caption-text">Click to view full size</p></div>
<p>&nbsp;</p>
<p>As you can see, the percentage they are asking for is the amount of free space to leave on the index pages, and NOT the fillfactor for the index pages. Had I read this screen more carefully yesterday, I would have saved myself and my colleagues much pain and suffering today (a database with 90% free space in the indexes doesn&#8217;t perform well AT ALL&#8230;lol). <img src='http://i0.wp.com/www.sqldiablo.com/wp-includes/images/smilies/icon_sad.gif?w=584' alt=':-(' class='wp-smiley' data-recalc-dims="1" /> </p>
<div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/SqlDiablo?a=GAcX1geh7R8:HWBZBqOG7PE:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/SqlDiablo?d=yIl2AUoC8zA" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/SqlDiablo/~4/GAcX1geh7R8" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.sqldiablo.com/2012/05/08/maintenance-plan-index-rebuild-gotcha/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://www.sqldiablo.com/2012/05/08/maintenance-plan-index-rebuild-gotcha/?utm_source=rss&amp;utm_medium=rss&amp;utm_campaign=maintenance-plan-index-rebuild-gotcha</feedburner:origLink></item>
		<item>
		<title>Service Broker &amp; AlwaysOn Availability Groups: Odd Transmission Queue Behavior</title>
		<link>http://feedproxy.google.com/~r/SqlDiablo/~3/zgFHTP68VrA/</link>
		<comments>http://www.sqldiablo.com/2012/04/15/service-broker-alwayson-availability-groups-odd-transmission-queue-behavior/#comments</comments>
		<pubDate>Sun, 15 Apr 2012 19:02:48 +0000</pubDate>
		<dc:creator>SQL Diablo</dc:creator>
				<category><![CDATA[AlwaysOn]]></category>
		<category><![CDATA[Database Administration]]></category>
		<category><![CDATA[Development]]></category>
		<category><![CDATA[Service Broker]]></category>
		<category><![CDATA[SQL Server]]></category>
		<category><![CDATA[SQL Server 2012]]></category>
		<category><![CDATA[Availability Groups]]></category>

		<guid isPermaLink="false">http://www.sqldiablo.com/?p=230</guid>
		<description><![CDATA[I&#8217;ve been working on a project over the past several months that will utilize Service Broker and AlwaysOn Availability Groups to meet some of the HA and DR goals of the company I work for (more info here). Just recently, &#8230; <a href="http://www.sqldiablo.com/2012/04/15/service-broker-alwayson-availability-groups-odd-transmission-queue-behavior/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
				<content:encoded><![CDATA[<p>I&#8217;ve been working on a project over the past several months that will utilize Service Broker and AlwaysOn Availability Groups to meet some of the HA and DR goals of the company I work for (<a title="Service Broker Replication" href="http://www.sqldiablo.com/service-broker-replication/" target="_blank">more info here</a>). Just recently, I was able to implement the full solution in my development lab and point an instance of our website at it. While we were working out some kinks in our database and website to get the two working well with my Service Broker Replication project, I began noticing some odd behavior in Service Broker when it&#8217;s used with AlwaysOn Availability Groups, and I wanted to blog about it in an attempt to see if anyone else has seen this issue and might have an idea how to address it.</p>
<p>Update: I&#8217;ve also posted this question on <a href="http://dba.stackexchange.com/questions/16579/service-broker-alwayson-availability-groups-odd-transmission-queue-behavior" target="_blank">DBA.StackExchange.com</a>.</p>
<h1>The Setup:</h1>
<p>I have a Hyper-V host running 6 Windows Server 2008 R2 VMs (BTDevSQLVM1-BTDevSQLVM6). The VMs are grouped into 2-node WSFCs with node and file share quorum. I&#8217;ve installed standalone SQL 2012 Developer Edition instances on each of the VMs, and created an Availability Group with a listener on each cluster (SBReplDistrib, SBRepl1, &amp; SBRepl2).</p>
<p>For the purpose of this blog post, I&#8217;ll be focusing on the communication between SBRepl1 and SBReplDistrib. The illustration below shows the Service Broker objects for each side of the conversation:</p>
<p><a href="http://i2.wp.com/www.sqldiablo.com/wp-content/uploads/2012/04/SBRepl-Service-Broker-Objects1.jpg" target="_blank"><img class="alignnone size-full wp-image-233" title="SBRepl - Service Broker Objects" src="http://i2.wp.com/www.sqldiablo.com/wp-content/uploads/2012/04/SBRepl-Service-Broker-Objects1.jpg?resize=584%2C941" alt="" data-recalc-dims="1" /></a></p>
<p>The Service Broker endpoints and routes are setup per <a title="Service Broker with AlwaysOn Availability Groups (SQL Server)" href="http://msdn.microsoft.com/en-us/library/hh710058.aspx" target="_blank">this MSDN article</a>.The SBRepl_Receive route in MSDB is for the local server&#8217;s service (//SBReplDistrib/SBRepl on SBReplDistrib, and //SBRepl1/SBRepl on SBRepl1), and points to the local instance. The SBRepl_Send route on SBRepl1 maps service //SBReplDistrib/SBRepl to TCP://SBReplDistrib:4022, and the SBRepl_Send_SBRepl1 route on SBReplDistrib is a similar mapping for the service on SBRepl1.</p>
<h1>The Expected Behavior:</h1>
<p>My understanding of how Service Broker handles message sending and receiving is thus (This is pretty simplified. There is a lot more detail about this process in&nbsp;Klaus Aschenbrenner&#8217;s (<a href="http://www.sqlpassion.at/blog/" target="_blank">blog</a> | <a href="https://twitter.com/#!/Aschenbrenner" target="_blank">twitter</a>) book <a title="Pro SQL Server 2008 Service Broker" href="http://www.apress.com/9781590599990" target="_blank">&#8220;Pro SQL Server 2008 Service Broker&#8221;</a>):</p>
<ol>
<li>The initiator app creates a message (in this case, well formed XML)</li>
<li>If there is an existing dialog conversation between the initiator service and the target service that is in the conversing status, the app can simply send the message on the existing conversation handle. Otherwise, the initiator app should begin a dialog conversation between the initiator service and the target service and send the message on that conversation handle.</li>
<li>The message is placed in the sys.transmission_queue system table and Service Broker begins making attempts to deliver the message to the target service.</li>
<li>Service Broker looks for an appropriate route and remote service binding and uses them to determine the address to connect to in order to deliver the message.</li>
<li>Service Broker opens a connection to the target, authenticates, and delivers the message to the target service broker.</li>
<li>The target Service Broker attempts to classify the message and determine what local service will handle the message (it uses route data in the msdb database for this).</li>
<li>The target Service Broker delivers the message to the target service&#8217;s queue</li>
<li>Once the message is successfully delivered to the target queue, the target Service Broker looks for route information back to the initiator and attempts to deliver an acknowledgement that the message was received.</li>
<li>The initiator&#8217;s Service Broker receives the acknowledgement and uses routing information in MSDB to determine what local service the acknowledgement is for.</li>
<li>Upon successful routing of the acknowledgement to the initiating service, the message is then removed from the sys.transmission_queue system table.</li>
<li>If the initiator does not receive an acknowledgement that the message was received, it will periodically retry delivering the message to the target. If the target has already received the message, it will simply drop any additional delivery retries and send acknowledgements for them.</li>
</ol>
<h1>The Odd Behavior:</h1>
<p>Step 11 is where I am seeing some very odd behavior with Service Broker and AlwaysOn. I see the message getting delivered to the target and processed successfully, and I also see the acknowledgement getting sent back to the initiator and received. However, the message remains in sys.transmission_queue as though no acknowledgement was received. To make things even more strange, Service Broker isn&#8217;t attempting to resend the message like I would expect it to if the acknowledgement wasn&#8217;t received. Instead, the message simply remain in the sys.transmission_queue, and as new messages are sent, they get delivered, acknowledged, and they too remain in the sys.transmission_queue. It seems to me like service broker is getting the acknowledgements and therefore stops trying to deliver the message, but doesn&#8217;t remove it from the sys.transmission_queue for some reason. The transmission_status for these messages remains blank, which should indicate that Service Broker hasn&#8217;t attempted to deliver them yet.</p>
<p>I checked the retention setting on the service queue, and it is set to off, but that should only impact the service queue and not the sys.transmission_queue. I have also traced both sides of the conversation using SQL Profiler, and I am able to see the message getting sent and the acknowledgement being sent back to the initiator and getting received (see XML trace data at the end of this post).</p>
<p>One odd thing did jump out at me in the traces though. I noticed that both sides seemed to be a bit confused about the TCP connections, because messages are sent from the IP address of the node itself while the service routes and the messages themselves point to the name/IP of the AG listener. This confusion appears to be causing each side to close the existing connection between the two services and create a new one in order to deliver a message or acknowledgement. I&#8217;m not sure if this is normal or not or if it has anything to do with why the acknowledgements aren&#8217;t being handled correctly, but it was the only thing I could see that could possibly explain the odd behavior.</p>
<h1>The Plea for Help:</h1>
<p>At this time, I don&#8217;t have a solution to this message retention issue other than to manually end the conversation with cleanup on both sides, and that&#8217;s not really something I want to do. If you have any ideas as to why this might be happening or what I can do about it, please leave me a comment and let me know. If there is any additional information that you would like me to provide about my setup or about the issue, please let me know in the comments as well. I will post a followup to this post if/when I find a solution to this issue.</p>
<h1>The Trace Data:</h1>
<p>I&#8217;ve removed the trace data from this blog post for brevity and security reasons. Please leave me a comment if you would like to review the trace files.</p>
<div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/SqlDiablo?a=zgFHTP68VrA:DXl_PBHAXa4:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/SqlDiablo?d=yIl2AUoC8zA" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/SqlDiablo/~4/zgFHTP68VrA" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.sqldiablo.com/2012/04/15/service-broker-alwayson-availability-groups-odd-transmission-queue-behavior/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		<feedburner:origLink>http://www.sqldiablo.com/2012/04/15/service-broker-alwayson-availability-groups-odd-transmission-queue-behavior/?utm_source=rss&amp;utm_medium=rss&amp;utm_campaign=service-broker-alwayson-availability-groups-odd-transmission-queue-behavior</feedburner:origLink></item>
		<item>
		<title>Service Broker Replication – System Overview</title>
		<link>http://feedproxy.google.com/~r/SqlDiablo/~3/HINek_TBKk8/</link>
		<comments>http://www.sqldiablo.com/2012/03/19/service-broker-replication-system-overview/#comments</comments>
		<pubDate>Mon, 19 Mar 2012 12:41:07 +0000</pubDate>
		<dc:creator>SQL Diablo</dc:creator>
				<category><![CDATA[Database Administration]]></category>
		<category><![CDATA[Development]]></category>
		<category><![CDATA[Service Broker]]></category>
		<category><![CDATA[SQL Server]]></category>
		<category><![CDATA[SQL Server 2005]]></category>
		<category><![CDATA[SQL Server 2008]]></category>
		<category><![CDATA[SQL Server 2012]]></category>
		<category><![CDATA[Disaster Recovery]]></category>
		<category><![CDATA[High Availability]]></category>
		<category><![CDATA[Projects]]></category>
		<category><![CDATA[Replication]]></category>
		<category><![CDATA[SQL]]></category>

		<guid isPermaLink="false">http://www.sqldiablo.com/?p=197</guid>
		<description><![CDATA[Service Broker Replication &#8211; Table of Contents System Overview In my previous posts, I explained how Service Broker works and why I chose it as part of a solution to our HA &#38; DR problem. In this post, I&#8217;ll give &#8230; <a href="http://www.sqldiablo.com/2012/03/19/service-broker-replication-system-overview/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
				<content:encoded><![CDATA[<p><a title="Service Broker Replication - Table of Contents" href="http://www.sqldiablo.com/service-broker-replication/"><strong>Service Broker Replication &#8211; Table of Contents</strong></a></p>
<h1><strong><span style="text-decoration: underline;">System Overview</span></strong></h1>
<p>In my previous posts, I explained how Service Broker works and why I chose it as part of a solution to our HA &amp; DR problem. In this post, I&#8217;ll give a high-level overview of the solution and the replication model I chose. I will go into further detail on the various aspects of the solution in future blog posts in this series (including how AlwaysOn Availability Groups can be used with this system).</p>
<h2>Replication Model</h2>
<p>For this project, I evaluated two models for replication: a mesh (peer to peer) &amp; a distributor-subscriber model. In a mesh, every replication partner sends its changes to every other replication partner and consequently receives changes from every other replication partner as well. The benefits of this model are that it has a low latency for changes to be applied and there is no single point of failure. If any replication partner goes down, the remaining replication partners stay up and continue to synchronize with each other. However, there is a large amount of setup and maintenance needed for this model, and it increases exponentially as new replication partners are added (the more replication partners you add, the more services/queues/routes, etc there are to add and manage).</p>
<p>With a distributor-subscriber model, each replication partner sends its changes to the distributor, and the distributor then relays those changes to the other replication partners. Therefore, each replication partner only really receives changes from the distributor. The benefits are simpler setup and maintenance (each replication partner only needs to communicate with the distributor instead of communicating with every other replication partner) as well as the ability to easily log the order in which changes are made in the environment (I&#8217;ll explain why this is important later). The drawbacks to this model are that the distributor becomes a single point of failure (AlwaysOn Availability Groups can help with this problem), and slightly increased latency for changes to be replicated throughout the environment.</p>
<p>In the end, I decided to go with the distributor-subscriber model because of the maintenance nightmare that a mesh can become and because with a mesh, it can be very difficult to bring on a new replication partner and synchronize it (this is because there is no single list of the changes that are being made in the environment and no guarantee as to the order those changes will be applied at any given replication partner). By having a centralized distributor that coordinates all communications, the system knows exactly what changes are being made and in what order, so it becomes much easier to take backups at any replication partner or bring a new replication partner online (I will describe the processes of taking backups and bringing on new replication partners in later posts in this series).</p>
<h2>Service Broker Topology &amp; Security</h2>
<p>In keeping with the theme of simplicity and ease of management, each replication partner has a single queue, service, and message type that handle both sending &amp; receiving changes to and from the distributor. This also ensures that changes will be sent (and applied) in the order that they occur. However, I still wanted a logical way to separate the kinds of messages being sent between the replication partners. The easiest and most extensible way I came up with was to just declare what kind of message was being sent as the name of the root node of the XML message (see the example below). This allows me to add additional types as needed in the future without having to alter the service broker objects themselves. The three kinds of messages I came up with are DML messages, DDL messages, and COMMAND messages. I will go into more detail on these message kinds in future posts in this series.</p>
<pre>&lt;DML OriginatingServerName=&quot;ReplPartner1&quot; SentUTCDate=&quot;2011-11-10 14:30:39.7779946&quot; DistributorReceivedUTCDate=&quot;2011-11-10 14:30:39.9742583&quot; DistributorSentUTCDate=&quot;2011-11-10 14:30:40.0211474&quot;&gt;
  &lt;INSERT DatabaseName=&quot;TestDB&quot; SchemaName=&quot;dbo&quot; TableName=&quot;TestTable&quot;&gt;
    &lt;row&gt;
      &lt;Description&gt;Test Description 1&lt;/Description&gt;
      &lt;Name&gt;Test Name 1&lt;/Name&gt;
      &lt;ServerId&gt;2&lt;/ServerId&gt;
      &lt;TestTableId&gt;1&lt;/TestTableId&gt;
    &lt;/row&gt;
  &lt;/INSERT&gt;
&lt;/DML&gt;</pre>
<p>Since each replication partner should be able to have multiple databases participating in replication, I created a special database (SBRepl) just for the service broker objects and to store configuration options. However, this means that instead of using a database user without a login to execute the auto activation stored procedure for the queue, I had to use a database user with a login. This is because a database user without a login cannot be granted rights to other databases in the same instance. By using a login, I was able to have the auto activation stored procedure reside within the SBRepl database and have it apply changes to any other database within the instance (as long as I grant it the necessary rights to those databases). Conversely, any logins that make changes to a database that is replicated will also need rights to the SBRepl database to allow those changes to be replicated.</p>
<h2>Data-Driven Subscriptions and Supporting Objects</h2>
<p>In an effort to simplify management while still maintaining some control over what changes are replicated and to which replication partners, I decided to implement data-driven subscriptions. These subscription are broken into two parts: DML subscriptions and DDL subscriptions. DML subscriptions control which tables within a subscribed database to replicate data changes for. DDL changes control which DDL statements (create user, create table, alter procedure, etc.) to replicate for a subscribed database. Each subscription also indicates whether a given replication partner can send messages, receive messages, or both for that subscription. Therefore, a replication partner might be able to receive DML and DDL changes for a certain database, but not send them (or vice versa). This allows a subscribed database to be read-only, write-only, or read-write with respect to replication. In most environments, the subscriptions will be read-write, but I wanted the option to be there in case it was needed. As for DML and DDL subscriptions themselves, I will go into further detail about them in a later blog post in this series.</p>
<p>Up to this point, I&#8217;ve been describing the communication of changes. However, the system needs to be able to detect that changes were made in the first place. In order to do that, I decided to use a database trigger to detect DDL changes made within a replicated database and a DML trigger to detect changes made to data in a replicated table. Each of these triggers does 3 things: 1) Checks to see if the trigger was fired by a change being applied from another replication partner and stops execution of the trigger if it was (this prevents looping within the replication environment) 2) Checks the DML or DDL subscriptions to see if it is &#8220;allowed&#8221; to send these changes to the other replication partners and stops execution of the trigger if it is not 3) Gathers the changes into one or more messages and sends them to the distributor. I will cover the database and table triggers in more detail in a future post.</p>
<p><a title="Service Broker Replication - Table of Contents" href="http://www.sqldiablo.com/service-broker-replication/"><strong>Service Broker Replication &#8211; Table of Contents</strong></a></p>
<div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/SqlDiablo?a=HINek_TBKk8:LAqmosapazI:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/SqlDiablo?d=yIl2AUoC8zA" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/SqlDiablo/~4/HINek_TBKk8" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.sqldiablo.com/2012/03/19/service-broker-replication-system-overview/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://www.sqldiablo.com/2012/03/19/service-broker-replication-system-overview/?utm_source=rss&amp;utm_medium=rss&amp;utm_campaign=service-broker-replication-system-overview</feedburner:origLink></item>
	</channel>
</rss>
