<?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/"
	xmlns:georss="http://www.georss.org/georss" xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#" xmlns:media="http://search.yahoo.com/mrss/"
	>

<channel>
	<title>SQL Server Sleuth</title>
	<atom:link href="http://sqlserversleuth.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://sqlserversleuth.com</link>
	<description>For DBAs that enjoy a good mystery</description>
	<lastBuildDate>Sat, 01 Oct 2011 06:04:22 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.com/</generator>
<cloud domain='sqlserversleuth.com' port='80' path='/?rsscloud=notify' registerProcedure='' protocol='http-post' />
<image>
		<url>http://0.gravatar.com/blavatar/a9ab64e4b3cc6d92ec2c225a7d6ea0bd?s=96&#038;d=http%3A%2F%2Fs2.wp.com%2Fi%2Fbuttonw-com.png</url>
		<title>SQL Server Sleuth</title>
		<link>http://sqlserversleuth.com</link>
	</image>
	<atom:link rel="search" type="application/opensearchdescription+xml" href="http://sqlserversleuth.com/osd.xml" title="SQL Server Sleuth" />
	<atom:link rel='hub' href='http://sqlserversleuth.com/?pushpress=hub'/>
		<item>
		<title>Tutorial &#8211; Installing PowerShell</title>
		<link>http://sqlserversleuth.com/2011/06/04/tutorial-installing-powershell/</link>
		<comments>http://sqlserversleuth.com/2011/06/04/tutorial-installing-powershell/#comments</comments>
		<pubDate>Sun, 05 Jun 2011 04:50:16 +0000</pubDate>
		<dc:creator>tnbarkhouse</dc:creator>
				<category><![CDATA[PowerShell]]></category>
		<category><![CDATA[.NET Framework]]></category>
		<category><![CDATA[getting started]]></category>
		<category><![CDATA[patches]]></category>
		<category><![CDATA[tutorial]]></category>
		<category><![CDATA[Windows]]></category>
		<category><![CDATA[Windows 2000]]></category>
		<category><![CDATA[Windows 7]]></category>
		<category><![CDATA[Windows Server 2003]]></category>
		<category><![CDATA[Windows Server 2008]]></category>
		<category><![CDATA[Windows Server 2008 R2]]></category>
		<category><![CDATA[Windows Vista]]></category>
		<category><![CDATA[Windows XP]]></category>
		<category><![CDATA[WinRM]]></category>

		<guid isPermaLink="false">http://sqlserversleuth.com/?p=326</guid>
		<description><![CDATA[Unfortunately there are a few different ways to install PowerShell, depending on the version of Windows. This tutorial provides the installation steps that are appropriate for your operating system. Note: Before attempting to install PowerShell on a computer, confirm that &#8230; <a href="http://sqlserversleuth.com/2011/06/04/tutorial-installing-powershell/">Continue reading <span class="meta-nav">&#8594;</span></a><img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=sqlserversleuth.com&amp;blog=6775699&amp;post=326&amp;subd=tnbarkhouse&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Unfortunately there are a few different ways to install <a href="http://technet.microsoft.com/en-us/scriptcenter/dd742419.aspx" target="_blank">PowerShell</a>, depending on the version of <a href="http://technet.microsoft.com/en-us/library/cc498727.aspx" target="_blank">Windows</a>.  This tutorial provides the installation steps that are appropriate for your operating system.</p>
<p><span style="font-weight:bold;">Note:</span> Before attempting to install PowerShell on a computer, confirm that <a href="/2011/06/04/tutorial-determining-whether-powershell-is-installed/" target="_blank">it isn&#8217;t already installed</a>!</p>
<p>PowerShell version 1.0 was available for installation <a href="http://support.microsoft.com/default.aspx?scid=kb;en-us;926139" target="_blank">by itself</a>.  PowerShell version 2.0 is installed as part of the <a href="http://support.microsoft.com/default.aspx?scid=kb;en-us;968929" target="_blank">Windows Management Framework</a>.  Don&#8217;t worry&#8230; <a href="http://msdn.microsoft.com/en-us/library/aa384426%28v=VS.85%29.aspx" target="_blank">WinRM</a> is disabled by default, so this update can be safely installed without affecting the security of Windows.</p>
<h3>Steps Common to Each Windows Operating System</h3>
<div>
<p>There are a few requirements for installing PowerShell on Windows:</p>
<ol>
<li>Confirm that you have sufficient security privileges for installing software on Windows</li>
<li>Verify that the pre-requisite—<a href="http://msdn.microsoft.com/en-us/netframework/aa731542" target="_blank">version 2.0</a> of the <a href="http://www.microsoft.com/net/" target="_blank">.NET Framework</a>—is installed (and patched)</li>
<li>
                    Make sure that your system is up-to-date with its <a href="http://windows.microsoft.com/en-US/windows/downloads/service-packs" target="_blank">Service Pack</a> and <a href="http://windows.microsoft.com/en-US/windows/help/windows-update" target="_blank">patches</a>:</p>
<table style="margin-left:25px;margin-top:15px;width:95%;" summary="Minimum Service Pack levels for installing PowerShell 2.0">
<tr>
<th>Windows Version</th>
<th>Minimum Service Pack</th>
</tr>
<tr>
<td>Windows Server 2008</td>
<td><a href="http://technet.microsoft.com/en-us/windows/dd262148" target="_blank">Service Pack 2</a></td>
</tr>
<tr>
<td>Windows Vista</td>
<td><a href="http://technet.microsoft.com/en-us/windows/dd262148" target="_blank">Service Pack 2</a></td>
</tr>
<tr>
<td>Windows Server 2003 R2</td>
<td><a href="http://technet.microsoft.com/en-us/windowsserver/bb463273" target="_blank">Service Pack 2</a></td>
</tr>
<tr>
<td>Windows Server 2003</td>
<td><a href="http://technet.microsoft.com/en-us/windowsserver/bb463273" target="_blank">Service Pack 2</a></td>
</tr>
<tr>
<td>Windows XP</td>
<td><a href="http://technet.microsoft.com/en-us/windows/bb794714" target="_blank">Service Pack 3</a></td>
</tr>
</table>
</li>
</ol>
</p></div>
<h3>Installation on Windows 7 or Windows Server 2008 R2</h3>
<div>
<p>PowerShell <span style="font-style:italic;">should already be</span> installed and enabled.  Inability to run PowerShell on a <a href="http://technet.microsoft.com/en-us/windows/dd361745" target="_blank">Windows 7</a> or <a href="http://technet.microsoft.com/en-us/library/dd349801(WS.10).aspx" target="_blank">Windows Server 2008 R2</a> machine indicates a problem, or it has been removed/locked down by your system administrator.</p>
</p></div>
<h3>Installation on Windows Server 2008 or Windows Vista</h3>
<div>
<ol>
<li>
                    Review the information on the <a href="http://support.microsoft.com/default.aspx?scid=kb;en-us;968929" target="_blank">Windows Management Framework Core</a> update
                </li>
<li>
                    Download the update package (&#8220;Windows6.0-KB968930-*.msu&#8221;) that is appropriate for your computer&#8217;s <a href="http://msdn.microsoft.com/en-us/library/ff553442%28v=vs.85%29.aspx" target="_blank">processor architecture</a>
                </li>
<li>
                    Double-click on the &#8220;Windows6.0-KB968930-*.msu&#8221; file (that you just downloaded) to install it
                </li>
</ol></div>
<h3>Installation on Windows Server 2003</h3>
<div>
<ol>
<li>
                    Verify that version 2.0 of the .NET Framework is installed:</p>
<ol>
<li>
                                Open the <span style="font-style:italic;">Windows</span>&reg; <span style="font-style:italic;">Run</span> dialog box</p>
<ol>
<li>Press the <img src="http://tnbarkhouse.files.wordpress.com/2011/06/keyboardimages_vk_lwin.png?w=640" alt="Windows key"> + <img src="http://tnbarkhouse.files.wordpress.com/2011/06/keyboardimages_vk_r.png?w=640" alt="R key"> keys</li>
</ol>
</li>
<li>
                                Type <span style="font-style:italic;">Cmd.exe</span> into the <span style="font-style:italic;">Open</span> text box and press the <img src="http://tnbarkhouse.files.wordpress.com/2011/06/keyboardimages_vk_return.png?w=640" alt="Enter key"> key
                            </li>
<li>
<p>At the command prompt, type the following command line and press the <img src="http://tnbarkhouse.files.wordpress.com/2011/06/keyboardimages_vk_return.png?w=640" alt="Enter key"> key:</p>
<p><span style="font-style:italic;">dir %SYSTEMROOT%\Microsoft.NET\Framework\ /AD /B</span></p>
</li>
<li>
<p>The .NET Framework pre-requisite is satisfied if the <span style="font-style:italic;">dir</span> output of the command includes a substring of &#8220;v2.0.50727&#8243;.  Otherwise, <a href="http://www.microsoft.com/downloads/en/details.aspx?familyid=5B2C0358-915B-4EB5-9B1D-10E506DA9D0F&amp;displaylang=en" target="_blank">download</a> and install version 2.0 or later of the .NET Framework</p>
<ul>
<li>You could (and probably should) install the <a href="http://msdn.microsoft.com/en-us/netframework/aa569263" target="_blank">latest version</a> (each release of the .NET Framework includes each of the ones that precede it)</li>
<li><span style="font-style:italic;">Be sure to check for and apply <a href="http://update.microsoft.com/" target="_blank">Windows updates</a> afterward; there are Service Packs and patches for each version of the .NET Framework!</span></li>
</ul>
</li>
</ol>
</li>
<li>
                    Review the information on the <a href="http://support.microsoft.com/default.aspx?scid=kb;en-us;968929" target="_blank">Windows Management Framework Core</a> update
                </li>
<li>
                    Download the installation program (&#8220;WindowsServer2003-KB968930-*-ENG.exe&#8221;) that is appropriate for your computer&#8217;s <a href="http://msdn.microsoft.com/en-us/library/ff553442%28v=vs.85%29.aspx" target="_blank">processor architecture</a>
                </li>
<li>
                    Double-click on the &#8220;WindowsServer2003-KB968930-*-ENG.exe&#8221; file (that you just downloaded) to install it
                </li>
</ol></div>
<h3>Installation on Windows XP</h3>
<div>
<ol>
<li>
                    Verify that version 2.0 of the .NET Framework is installed:</p>
<ol>
<li>
                                Open the <span style="font-style:italic;">Windows</span>&reg; <span style="font-style:italic;">Run</span> dialog box</p>
<ol>
<li>Press the <img src="http://tnbarkhouse.files.wordpress.com/2011/06/keyboardimages_vk_lwin.png?w=640" alt="Windows key"> + <img src="http://tnbarkhouse.files.wordpress.com/2011/06/keyboardimages_vk_r.png?w=640" alt="R key"> keys</li>
</ol>
</li>
<li>
                                Type <span style="font-style:italic;">Cmd.exe</span> into the <span style="font-style:italic;">Open</span> text box and press the <img src="http://tnbarkhouse.files.wordpress.com/2011/06/keyboardimages_vk_return.png?w=640" alt="Enter key"> key
                            </li>
<li>
<p>At the command prompt, type the following command line and press the <img src="http://tnbarkhouse.files.wordpress.com/2011/06/keyboardimages_vk_return.png?w=640" alt="Enter key"> key:</p>
<p><span style="font-style:italic;">dir %SYSTEMROOT%\Microsoft.NET\Framework\ /AD /B</span></p>
</li>
<li>
<p>The .NET Framework pre-requisite is satisfied if the <span style="font-style:italic;">dir</span> output of the command includes a substring of &#8220;v2.0.50727&#8243;.  Otherwise, <a href="http://www.microsoft.com/downloads/en/details.aspx?familyid=5B2C0358-915B-4EB5-9B1D-10E506DA9D0F&amp;displaylang=en" target="_blank">download</a> and install version 2.0 or later of the .NET Framework</p>
<ul>
<li>You could (and probably should) install the <a href="http://msdn.microsoft.com/en-us/netframework/aa569263" target="_blank">latest version</a>—each release of the .NET Framework includes each of the ones that precede it</li>
<li><span style="font-style:italic;">Be sure to check for and apply <a href="http://update.microsoft.com/" target="_blank">Windows updates</a> afterward; there are Service Packs and patches for each version of the .NET Framework!</span></li>
</ul>
</li>
</ol>
</li>
<li>
                    Review the information on the <a href="http://support.microsoft.com/default.aspx?scid=kb;en-us;968929" target="_blank">Windows Management Framework Core</a> update
                </li>
<li>
                    Download the installation program (&#8220;WindowsXP-KB968930-x86-ENG.exe&#8221;)
                </li>
<li>
                    Double-click on the &#8220;WindowsXP-KB968930-x86-ENG.exe&#8221; file (that you just downloaded) to install it
                </li>
</ol></div>
<h3>Installation on Windows 2000</h3>
<div>
<p>PowerShell cannot be installed on <a href="http://technet.microsoft.com/en-us/windowsserver/bb643141.aspx" target="_blank">Windows 2000</a>&#8230; <span style="font-weight:bold;"><a href="http://support.microsoft.com/ph/1131" target="_blank">it&#8217;s time to upgrade!</a></span></p>
</p></div>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/tnbarkhouse.wordpress.com/326/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/tnbarkhouse.wordpress.com/326/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/tnbarkhouse.wordpress.com/326/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/tnbarkhouse.wordpress.com/326/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/tnbarkhouse.wordpress.com/326/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/tnbarkhouse.wordpress.com/326/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/tnbarkhouse.wordpress.com/326/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/tnbarkhouse.wordpress.com/326/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/tnbarkhouse.wordpress.com/326/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/tnbarkhouse.wordpress.com/326/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/tnbarkhouse.wordpress.com/326/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/tnbarkhouse.wordpress.com/326/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/tnbarkhouse.wordpress.com/326/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/tnbarkhouse.wordpress.com/326/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=sqlserversleuth.com&amp;blog=6775699&amp;post=326&amp;subd=tnbarkhouse&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://sqlserversleuth.com/2011/06/04/tutorial-installing-powershell/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/a662186ae400e1e95ffca05d7b474fd7?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">tnbarkhouse</media:title>
		</media:content>

		<media:content url="http://tnbarkhouse.files.wordpress.com/2011/06/keyboardimages_vk_lwin.png" medium="image">
			<media:title type="html">Windows key</media:title>
		</media:content>

		<media:content url="http://tnbarkhouse.files.wordpress.com/2011/06/keyboardimages_vk_r.png" medium="image">
			<media:title type="html">R key</media:title>
		</media:content>

		<media:content url="http://tnbarkhouse.files.wordpress.com/2011/06/keyboardimages_vk_return.png" medium="image">
			<media:title type="html">Enter key</media:title>
		</media:content>

		<media:content url="http://tnbarkhouse.files.wordpress.com/2011/06/keyboardimages_vk_return.png" medium="image">
			<media:title type="html">Enter key</media:title>
		</media:content>

		<media:content url="http://tnbarkhouse.files.wordpress.com/2011/06/keyboardimages_vk_lwin.png" medium="image">
			<media:title type="html">Windows key</media:title>
		</media:content>

		<media:content url="http://tnbarkhouse.files.wordpress.com/2011/06/keyboardimages_vk_r.png" medium="image">
			<media:title type="html">R key</media:title>
		</media:content>

		<media:content url="http://tnbarkhouse.files.wordpress.com/2011/06/keyboardimages_vk_return.png" medium="image">
			<media:title type="html">Enter key</media:title>
		</media:content>

		<media:content url="http://tnbarkhouse.files.wordpress.com/2011/06/keyboardimages_vk_return.png" medium="image">
			<media:title type="html">Enter key</media:title>
		</media:content>
	</item>
		<item>
		<title>Tutorial &#8211; Determining whether PowerShell is installed</title>
		<link>http://sqlserversleuth.com/2011/06/04/tutorial-determining-whether-powershell-is-installed/</link>
		<comments>http://sqlserversleuth.com/2011/06/04/tutorial-determining-whether-powershell-is-installed/#comments</comments>
		<pubDate>Sun, 05 Jun 2011 04:12:39 +0000</pubDate>
		<dc:creator>tnbarkhouse</dc:creator>
				<category><![CDATA[PowerShell]]></category>
		<category><![CDATA[getting started]]></category>
		<category><![CDATA[tutorial]]></category>
		<category><![CDATA[Windows 7]]></category>
		<category><![CDATA[Windows Server 2008 R2]]></category>

		<guid isPermaLink="false">http://sqlserversleuth.com/?p=313</guid>
		<description><![CDATA[The first step in using PowerShell is making sure that it&#8217;s installed on the computer(s) that need it. As time passes, it will become as ubiquitous as Cmd.exe and VBScript. However, it&#8217;s currently important to verify that PowerShell is available &#8230; <a href="http://sqlserversleuth.com/2011/06/04/tutorial-determining-whether-powershell-is-installed/">Continue reading <span class="meta-nav">&#8594;</span></a><img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=sqlserversleuth.com&amp;blog=6775699&amp;post=313&amp;subd=tnbarkhouse&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>The first step in using <a href="http://technet.microsoft.com/en-us/scriptcenter/dd742419.aspx" target="_blank">PowerShell</a> is making sure that it&#8217;s installed on the computer(s) that need it.  As time passes, it will become as ubiquitous as <a href="http://technet.microsoft.com/en-us/library/cc756086(v=WS.10).aspx" target="_blank">Cmd.exe</a> and <a href="http://msdn.microsoft.com/en-us/library/t0aew7h6%28v=vs.85%29.aspx" target="_blank">VBScript</a>.  However, it&#8217;s currently important to verify that PowerShell is available when getting started.</p>
<p>Beginning with <a href="http://technet.microsoft.com/en-us/windows/dd361745" target="_blank">Windows 7</a> and <a href="http://technet.microsoft.com/en-us/windowsserver/bb310558.aspx" target="_blank">Windows Server 2008 R2</a>, PowerShell is installed and enabled by default.  As people realize its significance, more and more administrators and power users are installing PowerShell on earlier operating systems.  There&#8217;s a good chance that PowerShell is already installed on your computer, even if you didn&#8217;t put it there yourself!</p>
<p>Here are the steps for verifying that PowerShell is ready to use:</p>
<ol>
<li>
                Open the <span style="font-style:italic;">Windows</span>&reg; <span style="font-style:italic;">Run</span> dialog box</p>
<ol>
<li>Press the <img src="http://tnbarkhouse.files.wordpress.com/2011/06/keyboardimages_vk_lwin.png?w=640" alt="Windows key"> + <img src="http://tnbarkhouse.files.wordpress.com/2011/06/keyboardimages_vk_r.png?w=640" alt="R key"> keys</li>
</ol>
</li>
<li>
                Type <span style="font-style:italic;">PowerShell.exe</span> into the <span style="font-style:italic;">Open</span> text box and press the <img src="http://tnbarkhouse.files.wordpress.com/2011/06/keyboardimages_vk_return.png?w=640" alt="Enter key"> key
            </li>
</ol>
<ul>
<li>
<p>If PowerShell is installed, a <a href="http://msdn.microsoft.com/en-us/library/ms682010%28v=VS.85%29.aspx" target="_blank">console window</a> will be displayed:</p>
<p>                                <img src="http://tnbarkhouse.files.wordpress.com/2011/06/powershellconsole.png?w=640" style="margin-left:50px;margin-top:10px;"></p>
</li>
<li>
<p>If PowerShell is not installed, you will see the following error message:</p>
<pre style="color:red;margin-left:15px;"><span>Windows cannot find 'PowerShell.exe'. Make sure you typed the name correctly, and then try again.</span></pre>
<p>That means it&#8217;s time <a href="/2011/06/04/tutorial-installing-powershell/" target="_blank">install PowerShell</a>!</p>
</li>
</ul>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/tnbarkhouse.wordpress.com/313/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/tnbarkhouse.wordpress.com/313/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/tnbarkhouse.wordpress.com/313/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/tnbarkhouse.wordpress.com/313/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/tnbarkhouse.wordpress.com/313/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/tnbarkhouse.wordpress.com/313/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/tnbarkhouse.wordpress.com/313/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/tnbarkhouse.wordpress.com/313/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/tnbarkhouse.wordpress.com/313/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/tnbarkhouse.wordpress.com/313/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/tnbarkhouse.wordpress.com/313/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/tnbarkhouse.wordpress.com/313/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/tnbarkhouse.wordpress.com/313/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/tnbarkhouse.wordpress.com/313/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=sqlserversleuth.com&amp;blog=6775699&amp;post=313&amp;subd=tnbarkhouse&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://sqlserversleuth.com/2011/06/04/tutorial-determining-whether-powershell-is-installed/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/a662186ae400e1e95ffca05d7b474fd7?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">tnbarkhouse</media:title>
		</media:content>

		<media:content url="http://tnbarkhouse.files.wordpress.com/2011/06/keyboardimages_vk_lwin.png" medium="image">
			<media:title type="html">Windows key</media:title>
		</media:content>

		<media:content url="http://tnbarkhouse.files.wordpress.com/2011/06/keyboardimages_vk_r.png" medium="image">
			<media:title type="html">R key</media:title>
		</media:content>

		<media:content url="http://tnbarkhouse.files.wordpress.com/2011/06/keyboardimages_vk_return.png" medium="image">
			<media:title type="html">Enter key</media:title>
		</media:content>

		<media:content url="http://tnbarkhouse.files.wordpress.com/2011/06/powershellconsole.png" medium="image" />
	</item>
		<item>
		<title>Reflecting on my first CodeStock session</title>
		<link>http://sqlserversleuth.com/2011/06/03/reflecting-on-my-first-codestock-session/</link>
		<comments>http://sqlserversleuth.com/2011/06/03/reflecting-on-my-first-codestock-session/#comments</comments>
		<pubDate>Sat, 04 Jun 2011 03:15:32 +0000</pubDate>
		<dc:creator>tnbarkhouse</dc:creator>
				<category><![CDATA[SQL Server]]></category>
		<category><![CDATA[best practices]]></category>
		<category><![CDATA[CodeStock]]></category>
		<category><![CDATA[conferences]]></category>
		<category><![CDATA[feedback]]></category>
		<category><![CDATA[praise]]></category>
		<category><![CDATA[prescriptive guidance]]></category>
		<category><![CDATA[Profiler]]></category>
		<category><![CDATA[speaking]]></category>
		<category><![CDATA[SQL Trace]]></category>
		<category><![CDATA[Twitter]]></category>

		<guid isPermaLink="false">http://sqlserversleuth.com/?p=305</guid>
		<description><![CDATA[Today I gave my first of two presentations at the 2011 CodeStock conference, my &#8220;An Introduction to Profiler and SQL Trace&#8221; talk. The session went really well! It had good attendance, the audience was engaged and asked great questions, and &#8230; <a href="http://sqlserversleuth.com/2011/06/03/reflecting-on-my-first-codestock-session/">Continue reading <span class="meta-nav">&#8594;</span></a><img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=sqlserversleuth.com&amp;blog=6775699&amp;post=305&amp;subd=tnbarkhouse&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Today I gave my <a href="http://codestock.org/Sessions/an-introduction-to-profiler-and-sql-trace.aspx" target="_blank">first</a> of two presentations at the <a href="http://codestock.org/" target="_blank">2011 CodeStock</a> conference, my &#8220;<a href="/technical-presentations/sqltrace/" target="_blank">An Introduction to Profiler and SQL Trace</a>&#8221; talk.  The session went really well!  It had good attendance, the audience was engaged and asked great questions, and I am pleased with my delivery.  I also received the kind of feedback that justifies all of the work invested&#8230; an audience member, Stephen Horne (<a href="http://sqlstephenhorne.blogspot.com/" target="_blank">blog</a>, <a href="http://twitter.com/#!/SQLStephenHorne" target="_blank">Twitter</a>), said the following (in-person and <a href="http://twitter.com/#!/SQLStephenHorne/status/76719886272958465" target="_blank">on Twitter</a>):</p>
<p>    <blockQuote></p>
<p>I really enjoy seeing people talking passionately &amp; with significant knowledge about <a href="http://twitter.com/#!/search/%23SQL" target="_blank">#SQL</a> Server. <a href="http://twitter.com/#!/SQLServerSleuth" target="_blank">@SQLServerSleuth</a> <a href="http://twitter.com/#!/search/%23codestock" target="_blank">#codestock</a>.</p>
<p>    </blockQuote></p>
<p>During the session, I state that the following two ideas are the most important things to take away from the presentation:</p>
<ul>
<li><span style="font-weight:bold;">Do not run <a href="http://msdn.microsoft.com/en-us/library/ms187929.aspx" target="_blank">SQL Server Profiler</a> against a <a href="http://en.wikipedia.org/wiki/Production_Support" target="_blank">production</a> <a href="http://msdn.microsoft.com/en-us/library/bb545450.aspx" target="_blank">SQL Server</a> instance!</span>  Use a <a href="http://msdn.microsoft.com/en-us/library/ms191443.aspx" target="_blank">server-side trace</a> instead</li>
<li>Always place size and duration caps on your traces to limit their overhead and to protect against a run-away trace (see step three below)</li>
</ul>
<p>I spend a long time during the presentation warning against using Profiler (in production) and explaining its performance impact (as well as the overhead of tracing).  Still, Profiler can be a useful tool for defining trace sessions and analyzing trace data.  Here is the proper workflow for reaping its benefits without shooting yourself in the foot:</p>
<ol>
<li><span style="font-style:italic;">On your workstation</span>, use Profiler to define the trace (<a href="http://msdn.microsoft.com/en-us/library/ms175481.aspx" target="_blank">event classes</a>, <a href="http://msdn.microsoft.com/en-us/library/ms190762.aspx" target="_blank">columns</a>, and <a href="http://msdn.microsoft.com/en-us/library/ms175061.aspx" target="_blank">filters</a>)</li>
<li>
                Use Profiler to generate a <a href="http://en.wikipedia.org/wiki/Transact-SQL" target="_blank">Transact-SQL</a> script file with the <a href="http://msdn.microsoft.com/en-us/library/ms187346.aspx" target="_blank">system stored procedure</a> calls for a server-side trace:</p>
<p>                            <img src="http://tnbarkhouse.files.wordpress.com/2011/06/sqlserverprofiler_scripttracedefinition.png?w=640" style="margin-left:10px;margin-top:10px;"></p>
</li>
<li>Edit the script, including placing limits on the size <span style="font-style:italic;">and</span> duration of the trace (using the <span style="font-style:italic;">@maxfilesize</span> and <span style="font-style:italic;">@stoptime</span> parameters of the <a href="http://msdn.microsoft.com/en-us/library/ms190362.aspx" target="_blank">[sys].[sp_trace_create]</a> system stored procedure, as demonstrated in the presentation&#8217;s &#8220;<a href="/technical-presentations/sqltrace/" target="_blank">Demo 07_Create a server-side trace to provide information on the next deadlock(s),2005+.sql</a>&#8221; file)</li>
<li>Execute the script <span style="font-style:italic;">on the server</span> that is under investigation</li>
<li>If the trace automatically stops more quickly than expected, refine the trace definition to be more conservative</li>
<li>Once you have several trace files with useful data, <a href="http://7-zip.org/" target="_blank">compress them</a></li>
<li>Transfer the archive of compressed trace files from the target server to <span style="font-style:italic;">your workstation</span></li>
<li>Analyze the trace data using the <a href="http://msdn.microsoft.com/en-us/library/ms188425.aspx" target="_blank">[sys].[fn_trace_gettable]</a> system function and/or <a href="http://msdn.microsoft.com/en-us/library/ms175848.aspx" target="_blank">using Profiler</a></li>
</ol>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/tnbarkhouse.wordpress.com/305/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/tnbarkhouse.wordpress.com/305/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/tnbarkhouse.wordpress.com/305/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/tnbarkhouse.wordpress.com/305/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/tnbarkhouse.wordpress.com/305/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/tnbarkhouse.wordpress.com/305/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/tnbarkhouse.wordpress.com/305/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/tnbarkhouse.wordpress.com/305/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/tnbarkhouse.wordpress.com/305/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/tnbarkhouse.wordpress.com/305/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/tnbarkhouse.wordpress.com/305/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/tnbarkhouse.wordpress.com/305/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/tnbarkhouse.wordpress.com/305/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/tnbarkhouse.wordpress.com/305/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=sqlserversleuth.com&amp;blog=6775699&amp;post=305&amp;subd=tnbarkhouse&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://sqlserversleuth.com/2011/06/03/reflecting-on-my-first-codestock-session/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/a662186ae400e1e95ffca05d7b474fd7?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">tnbarkhouse</media:title>
		</media:content>

		<media:content url="http://tnbarkhouse.files.wordpress.com/2011/06/sqlserverprofiler_scripttracedefinition.png" medium="image" />
	</item>
		<item>
		<title>I am speaking at CodeStock 2011</title>
		<link>http://sqlserversleuth.com/2011/06/03/i-am-speaking-at-codestock-2011/</link>
		<comments>http://sqlserversleuth.com/2011/06/03/i-am-speaking-at-codestock-2011/#comments</comments>
		<pubDate>Fri, 03 Jun 2011 17:40:53 +0000</pubDate>
		<dc:creator>tnbarkhouse</dc:creator>
				<category><![CDATA[PowerShell]]></category>
		<category><![CDATA[SQL Server]]></category>
		<category><![CDATA[CodeStock]]></category>
		<category><![CDATA[conferences]]></category>
		<category><![CDATA[cookbooks]]></category>
		<category><![CDATA[Profiler]]></category>
		<category><![CDATA[speaking]]></category>
		<category><![CDATA[SQL Trace]]></category>

		<guid isPermaLink="false">http://sqlserversleuth.com/?p=299</guid>
		<description><![CDATA[I will be delivering two sessions at this year&#8217;s CodeStock conference in Knoxville, Tennessee: An Introduction to Profiler and SQL Trace at 2011-06-03 13:50-04:00. The session&#8217;s materials have been posted here. A PowerShell Cookbook for DBAs at 2011-06-04 09:50-04:00. The &#8230; <a href="http://sqlserversleuth.com/2011/06/03/i-am-speaking-at-codestock-2011/">Continue reading <span class="meta-nav">&#8594;</span></a><img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=sqlserversleuth.com&amp;blog=6775699&amp;post=299&amp;subd=tnbarkhouse&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>I will be delivering two sessions at this year&#8217;s <a href="http://codestock.org/" target="_blank">CodeStock conference</a> in <a href="http://en.wikipedia.org/wiki/Knoxville,_Tennessee" target="_blank">Knoxville, Tennessee</a>:</p>
<ul>
<li><a href="http://codestock.org/Sessions/an-introduction-to-profiler-and-sql-trace.aspx" target="_blank">An Introduction to Profiler and SQL Trace</a> at 2011-06-03 13:50-04:00.  The session&#8217;s materials have been posted <a href="/technical-presentations/sqltrace/" target="_blank">here</a>.</li>
<li><a href="http://codestock.org/Sessions/a-powershell-cookbook-for-dbas.aspx" target="_blank">A PowerShell Cookbook for DBAs</a> at 2011-06-04 09:50-04:00.  The session&#8217;s materials have been posted <a href="/technical-presentations/powershellcookbook/" target="_blank">here</a>.</li>
</ul>
<p>If you happen to be attending, please stop by and visit!</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/tnbarkhouse.wordpress.com/299/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/tnbarkhouse.wordpress.com/299/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/tnbarkhouse.wordpress.com/299/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/tnbarkhouse.wordpress.com/299/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/tnbarkhouse.wordpress.com/299/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/tnbarkhouse.wordpress.com/299/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/tnbarkhouse.wordpress.com/299/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/tnbarkhouse.wordpress.com/299/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/tnbarkhouse.wordpress.com/299/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/tnbarkhouse.wordpress.com/299/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/tnbarkhouse.wordpress.com/299/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/tnbarkhouse.wordpress.com/299/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/tnbarkhouse.wordpress.com/299/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/tnbarkhouse.wordpress.com/299/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=sqlserversleuth.com&amp;blog=6775699&amp;post=299&amp;subd=tnbarkhouse&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://sqlserversleuth.com/2011/06/03/i-am-speaking-at-codestock-2011/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/a662186ae400e1e95ffca05d7b474fd7?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">tnbarkhouse</media:title>
		</media:content>
	</item>
		<item>
		<title>Dealing with full transaction logs</title>
		<link>http://sqlserversleuth.com/2011/06/01/dealing-with-full-transaction-logs/</link>
		<comments>http://sqlserversleuth.com/2011/06/01/dealing-with-full-transaction-logs/#comments</comments>
		<pubDate>Thu, 02 Jun 2011 03:59:04 +0000</pubDate>
		<dc:creator>tnbarkhouse</dc:creator>
				<category><![CDATA[SQL Server]]></category>
		<category><![CDATA[backup]]></category>
		<category><![CDATA[bad practices]]></category>
		<category><![CDATA[catalog views]]></category>
		<category><![CDATA[full recovery model]]></category>
		<category><![CDATA[log backup chain]]></category>
		<category><![CDATA[point-in-time-recovery]]></category>
		<category><![CDATA[Recovery Point Objective]]></category>
		<category><![CDATA[shoulders of giants]]></category>
		<category><![CDATA[shrinking database files]]></category>
		<category><![CDATA[simple recovery model]]></category>
		<category><![CDATA[SQL Server errors]]></category>
		<category><![CDATA[transaction logs]]></category>

		<guid isPermaLink="false">http://sqlserversleuth.com/?p=284</guid>
		<description><![CDATA[In a recent post, I mentioned a customer that takes some perverse pleasure in undermining point-in-time-recoverability of their databases. Here are some more details on the bad practice and what I wish they would do instead. The customer has a &#8230; <a href="http://sqlserversleuth.com/2011/06/01/dealing-with-full-transaction-logs/">Continue reading <span class="meta-nav">&#8594;</span></a><img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=sqlserversleuth.com&amp;blog=6775699&amp;post=284&amp;subd=tnbarkhouse&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>In a recent <a href="/2011/05/19/code-snippet-reestablishing-the-backup-log-chain-with-powershell/" target="_blank">post</a>, I mentioned a customer that takes some perverse pleasure in undermining <a href="http://msdn.microsoft.com/en-us/library/ms178143.aspx" target="_blank">point-in-time-recoverability</a> of their databases.  Here are some more details on the bad practice and what I wish they would do instead.</p>
<p>The customer has a two-node <a href="http://www.microsoft.com/downloads/en/details.aspx?familyid=818234dc-a17b-4f09-b282-c6830fead499&amp;displaylang=en" target="_blank">failover cluster</a> with two instances of <a href="http://msdn.microsoft.com/en-us/library/ms166352%28SQL.90%29.aspx" target="_blank">SQL Server 2005</a>.  Each clustered instance has dozens of databases, nearly all of them with identical schema (they have a <a href="http://msdn.microsoft.com/en-us/library/cc966448.aspx" target="_blank">Data-Dependent Routing</a>/<a href="http://en.wikipedia.org/wiki/Shard_%28database_architecture%29" target="_blank">shard</a> architecture), and each is in the <a href="http://msdn.microsoft.com/en-us/library/ms189275.aspx" target="_blank">full recovery model</a>.  They don&#8217;t have enough disk space allocated for the instances and, much too frequently, they encounter <a href="http://msdn.microsoft.com/en-us/library/aa337278.aspx" target="_blank">9002 errors</a> from SQL Server (when one or more of the <a href="http://msdn.microsoft.com/en-us/library/ms190925.aspx" target="_blank">transaction log files</a> fill up and don&#8217;t have room to grow):</p>
<pre style="color:red;margin-left:15px;">Msg 9002, Level 17, State 1, Line 1
The transaction log for database '____' is full. To find out why space in the log cannot be reused, see the log_reuse_wait_desc column in sys.databases</pre>
<p>The customer reacts by looping through all of their databases and running <a href="http://msdn.microsoft.com/en-us/library/ms186865.aspx" target="_blank">BACKUP LOG &#8230; WITH NO_LOG</a> against each.  Let&#8217;s walk through the steps that they should be taking, instead of this knee-jerk overreaction.</p>
<p>The first problem is that, despite the hint in the 9002 error message, the customer doesn&#8217;t use the [log_reuse_wait_desc] column of the <a href="http://msdn.microsoft.com/en-us/library/ms178534.aspx" target="_blank">[sys].[databases]</a> catalog view to determine which databases need attention.  Instead, they resort to <a href="http://www.sqlservercentral.com/articles/Troubleshooting/66134/" target="_blank">shotgun troubleshooting</a> and truncate the transaction logs of all databases.</p>
<p>Next, the customer should perform appropriate <a href="http://en.wikipedia.org/wiki/Capacity_planning" target="_blank">capacity planning</a> and provision enough disk space for their databases (now and in the future).</p>
<p>Since the customer won&#8217;t acquire sufficient disk space, I have asked whether their databases really belong in the full recovery model.  They expect point-in-time-recoverability, but their frequent and ill-advised reaction to 9002 errors trashes the databases&#8217; <a href="http://msdn.microsoft.com/en-us/library/ms190440.aspx" target="_blank">backup log chains</a>.  It will be an upsetting day when they need to restore to a certain time and cannot do so.  It would be better to review the <a href="http://en.wikipedia.org/wiki/Recovery_point_objective" target="_blank">Recovery Point Objective (RPO)</a> for each database (or define it for the first time) and then place the majority of the databases in the <a href="http://msdn.microsoft.com/en-us/library/ms189275.aspx" target="_blank">simple recovery model</a>, saving the resources and administrative overhead associated with transaction log backups.  <a href="http://msdn.microsoft.com/en-us/library/ms175526.aspx" target="_blank">Differential backups</a> could be used to reduce data loss to levels consistent with the RPOs (<a href="http://en.wiktionary.org/wiki/your_mileage_may_vary" target="_blank">YMMV</a>).</p>
<p>As bad as it is to rely on sabotaged point-in-time-recoverability, the bigger issue is that the customer will follow-up the transaction log truncations with a round of shrinking the transaction log files!  I don&#8217;t have time right now to delve into the perils of shrinking transaction log files, so here are some great posts from others in the community:</p>
<ul>
<li><a href="http://www.sqlskills.com/blogs/paul/post/backup-log-with-no_log-use-abuse-and-undocumented-trace-flags-to-stop-it.aspx" target="_blank">BACKUP LOG WITH NO_LOG &#8211; use, abuse, and undocumented trace flags to stop it</a> by Paul Randal (<a href="http://www.sqlskills.com/blogs/Paul/" target="_blank">blog</a>, <a href="http://twitter.com/#!/PaulRandal" target="_blank">Twitter</a>)</li>
<li><a href="http://www.straightpathsql.com/archives/2009/01/dont-touch-that-shrink-button/" target="_blank">Don&#8217;t Touch that Shrink Button!</a> by Mike Walsh (<a href="http://www.straightpathsql.com/" target="_blank">blog</a>, <a href="http://twitter.com/#!/mike_walsh" target="_blank">Twitter</a>)</li>
<li><a href="http://sqlblog.com/blogs/tibor_karaszi/archive/2007/02/25/leaking-roof-and-file-shrinking.aspx" target="_blank">Leaking roof and file shrinking</a> by Tibor Karaszi (<a href="http://sqlblog.com/blogs/tibor_karaszi/default.aspx" target="_blank">blog</a>, <a href="http://twitter.com/#!/tiborkaraszi" target="_blank">Twitter</a>)</li>
</ul>
<p>If, despite careful planning and database administration, the transaction log for one of your databases fills up (and you receive a 9002 error), take a deep breath and simply back up the transaction log for that database.  It takes slightly longer than throwing away all of the committed transaction log records (via BACKUP LOG &#8230; WITH NO_LOG/TRUNCATE_ONLY) but it also avoids the problems discussed in this post and <a href="/2011/05/19/code-snippet-reestablishing-the-backup-log-chain-with-powershell/" target="_blank">the last one</a>.  If absolutely necessary, discard the committed transactions using the following process (which still works even after the wretched BACKUP LOG &#8230; WITH NO_LOG/TRUNCATE_ONLY functionality was <a href="http://msdn.microsoft.com/en-us/library/ms144262.aspx" target="_blank">removed from SQL Server</a>):</p>
<ol>
<li>
                Put the database in simple recovery model:</p>
<pre style="margin-left:15px;">ALTER DATABASE [YourDatabase] SET RECOVERY SIMPLE;</pre>
</li>
<li>
                Wait for the transaction log to automatically truncate&#8230; or force it:</p>
<pre style="margin-left:15px;">USE [YourDatabase];
GO
CHECKPOINT;
GO</pre>
</li>
<li>
                <span style="font-style:italic;">If the database truly belongs in full recovery model</span>:</p>
<ol>
<li>
                            Change the recovery model back:</p>
<pre style="margin-left:15px;">ALTER DATABASE [YourDatabase] SET RECOVERY FULL;</pre>
</li>
<li>Immediately perform a full backup of the database to reestablish the backup chain</li>
</ol>
</li>
</ol>
<p><span style="font-weight:bold;">Note:</span> While performing research for this post, I came across a similar <a href="http://sqlserverpedia.com/blog/sql-server-backup-and-restore/backup-log-with-truncate_only-like-a-bear-trap/" target="_blank">one</a> from Brent Ozar (<a href="http://www.brentozar.com/" target="_blank">blog</a>, <a href="http://twitter.com/#!/BrentO" target="_blank">Twitter</a>).  Despite the overlap, I decided to publish anyway, hoping that we rank higher in search engine results than all of the bad Internet advice that advocates forcibly clearing the transaction log!</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/tnbarkhouse.wordpress.com/284/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/tnbarkhouse.wordpress.com/284/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/tnbarkhouse.wordpress.com/284/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/tnbarkhouse.wordpress.com/284/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/tnbarkhouse.wordpress.com/284/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/tnbarkhouse.wordpress.com/284/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/tnbarkhouse.wordpress.com/284/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/tnbarkhouse.wordpress.com/284/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/tnbarkhouse.wordpress.com/284/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/tnbarkhouse.wordpress.com/284/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/tnbarkhouse.wordpress.com/284/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/tnbarkhouse.wordpress.com/284/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/tnbarkhouse.wordpress.com/284/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/tnbarkhouse.wordpress.com/284/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=sqlserversleuth.com&amp;blog=6775699&amp;post=284&amp;subd=tnbarkhouse&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://sqlserversleuth.com/2011/06/01/dealing-with-full-transaction-logs/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/a662186ae400e1e95ffca05d7b474fd7?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">tnbarkhouse</media:title>
		</media:content>
	</item>
		<item>
		<title>Query &#8211; Finding a DMV based on column names</title>
		<link>http://sqlserversleuth.com/2011/05/22/query-finding-a-dmv-based-on-column-names/</link>
		<comments>http://sqlserversleuth.com/2011/05/22/query-finding-a-dmv-based-on-column-names/#comments</comments>
		<pubDate>Sun, 22 May 2011 21:48:23 +0000</pubDate>
		<dc:creator>tnbarkhouse</dc:creator>
				<category><![CDATA[SQL Server]]></category>
		<category><![CDATA[catalog views]]></category>
		<category><![CDATA[CSS SQL Server]]></category>
		<category><![CDATA[DMVs]]></category>
		<category><![CDATA[meta data]]></category>
		<category><![CDATA[NTSSUG]]></category>
		<category><![CDATA[role models]]></category>
		<category><![CDATA[SQLskills Immersion]]></category>
		<category><![CDATA[training]]></category>
		<category><![CDATA[Transact-SQL]]></category>

		<guid isPermaLink="false">http://sqlserversleuth.com/?p=280</guid>
		<description><![CDATA[I really enjoyed the NTSSUG meeting on Thursday. Bob Ward (blog, Twitter), a major role model of mine, presented Inside SQL Server Wait Types. As with the SQLskills Immersion Events, I spent the whole time taking copious notes as the &#8230; <a href="http://sqlserversleuth.com/2011/05/22/query-finding-a-dmv-based-on-column-names/">Continue reading <span class="meta-nav">&#8594;</span></a><img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=sqlserversleuth.com&amp;blog=6775699&amp;post=280&amp;subd=tnbarkhouse&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>I really enjoyed the <a href="http://northtexas.sqlpass.org/" target="_blank">NTSSUG</a> meeting on Thursday.  Bob Ward (<a href="http://blogs.msdn.com/b/psssql/" target="_blank">blog</a>, <a href="http://twitter.com/#!/bobwardms" target="_blank">Twitter</a>), a major role model of mine, presented <a href="http://www.sqlpass.org/summit/eu2010/Agenda/SpotlightSessions/InsideSQLServerWaitTypes.aspx" target="_blank">Inside SQL Server Wait Types</a>.  As with the <a href="http://www.sqlskills.com/ImmersionEvents.asp" target="_blank">SQLskills Immersion Events</a>, I spent the whole time taking copious notes as the priceless information flowed.</p>
<p>While discussing <a href="http://blogs.msdn.com/b/psssql/archive/2009/11/03/the-sql-server-wait-type-repository.aspx" target="_blank">THREADPOOL</a> waits, I missed the name of a helpful <a href="http://msdn.microsoft.com/en-us/library/ms188754.aspx" target="_blank">DMV</a> for identifying a lack of <a href="http://blogs.msdn.com/b/khen1234/archive/2005/11/07/489778.aspx" target="_blank">worker threads</a>.  I <span style="font-style:italic;">did</span> hear the name of the relevant column though&#8230; &#8220;work_queue_count.&#8221;  Thanks to SQL Server&#8217;s <a href="http://msdn.microsoft.com/en-us/library/ms174365.aspx" target="_blank">catalog views</a>, it was easily to track down the DMV in question, <a href="http://msdn.microsoft.com/en-us/library/ms177526.aspx" target="_blank">[sys].[dm_os_schedulers]</a>:</p>
<pre style="margin-left:15px;">SELECT [_Objects].[object_id] AS [ObjectID],
    [_Objects].[name] AS [ObjectName],
    [_Objects].[type_desc] AS [ObjectType],
    [_Columns].[column_id] AS [ColumnID],
    [_Columns].[name] AS [ColumnName]
FROM [master].[sys].[system_objects] AS [_Objects]
INNER JOIN [master].[sys].[system_columns] AS [_Columns]
ON ([_Objects].[object_id] = [_Columns].[object_id])
WHERE (
    ([_Objects].[name] LIKE N'dm_%')
    AND
    ([_Objects].[type] IN ('IF', 'TF', 'V'))
    AND
    ([_Objects].[schema_id] = Schema_ID('sys'))
    AND
    ([_Objects].[is_ms_shipped] = 1)
    AND
    ([_Columns].[name] LIKE N'%work%queue%count%')
)
ORDER BY [_Objects].[name] ASC,
    [_Columns].[name] ASC;</pre>
<p>This type of query is also useful when searching for gems in <a href="http://www.microsoft.com/sqlserver/en/us/default.aspx" target="_blank">SQL Server&#8217;s</a> <a href="http://msdn.microsoft.com/en-us/library/ms187113.aspx" target="_blank">meta data</a>:</p>
<pre style="margin-left:15px;">SELECT [_Objects].[object_id] AS [ObjectID],
    [_Objects].[name] AS [ObjectName],
    [_Objects].[type_desc] AS [ObjectType],
    [_Columns].[column_id] AS [ColumnID],
    [_Columns].[name] AS [ColumnName]
FROM [master].[sys].[system_objects] AS [_Objects]
INNER JOIN [master].[sys].[system_columns] AS [_Columns]
ON ([_Objects].[object_id] = [_Columns].[object_id])
WHERE (
    ([_Objects].[type] IN ('IF', 'TF', 'V'))
    AND
    ([_Objects].[schema_id] = Schema_ID('sys'))
    AND
    ([_Objects].[is_ms_shipped] = 1)
)
ORDER BY [_Objects].[name] ASC,
    [_Columns].[column_id] ASC;</pre>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/tnbarkhouse.wordpress.com/280/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/tnbarkhouse.wordpress.com/280/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/tnbarkhouse.wordpress.com/280/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/tnbarkhouse.wordpress.com/280/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/tnbarkhouse.wordpress.com/280/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/tnbarkhouse.wordpress.com/280/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/tnbarkhouse.wordpress.com/280/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/tnbarkhouse.wordpress.com/280/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/tnbarkhouse.wordpress.com/280/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/tnbarkhouse.wordpress.com/280/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/tnbarkhouse.wordpress.com/280/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/tnbarkhouse.wordpress.com/280/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/tnbarkhouse.wordpress.com/280/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/tnbarkhouse.wordpress.com/280/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=sqlserversleuth.com&amp;blog=6775699&amp;post=280&amp;subd=tnbarkhouse&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://sqlserversleuth.com/2011/05/22/query-finding-a-dmv-based-on-column-names/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/a662186ae400e1e95ffca05d7b474fd7?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">tnbarkhouse</media:title>
		</media:content>
	</item>
		<item>
		<title>Please vote for PASS Summit 2011 sessions!</title>
		<link>http://sqlserversleuth.com/2011/05/19/please-vote-for-pass-summit-2011-sessions/</link>
		<comments>http://sqlserversleuth.com/2011/05/19/please-vote-for-pass-summit-2011-sessions/#comments</comments>
		<pubDate>Thu, 19 May 2011 20:21:52 +0000</pubDate>
		<dc:creator>tnbarkhouse</dc:creator>
				<category><![CDATA[PowerShell]]></category>
		<category><![CDATA[SQL Server]]></category>
		<category><![CDATA[conferences]]></category>
		<category><![CDATA[cookbooks]]></category>
		<category><![CDATA[deadlocks]]></category>
		<category><![CDATA[FWSSUG]]></category>
		<category><![CDATA[NTSSUG]]></category>
		<category><![CDATA[PASS]]></category>
		<category><![CDATA[speaking]]></category>
		<category><![CDATA[XML]]></category>

		<guid isPermaLink="false">http://sqlserversleuth.com/?p=274</guid>
		<description><![CDATA[I have been extremely fortunate to have spoken at the last two North American PASS Summits. The experiences have been amazing and I&#8217;m hopeful about getting a chance to present at this year&#8217;s conference too. I received very good feedback &#8230; <a href="http://sqlserversleuth.com/2011/05/19/please-vote-for-pass-summit-2011-sessions/">Continue reading <span class="meta-nav">&#8594;</span></a><img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=sqlserversleuth.com&amp;blog=6775699&amp;post=274&amp;subd=tnbarkhouse&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>I have been extremely fortunate to have spoken at the last two North American <a href="http://www.sqlpass.org/summit/" target="_blank">PASS Summits</a>.  The experiences have been amazing and I&#8217;m hopeful about getting a chance to present at this year&#8217;s conference too.  I received very good feedback from last year&#8217;s session, &#8220;<a href="/technical-presentations/deadlocks/" target="_blank">Deadlock Detection, Troubleshooting, and Prevention</a>&#8220;, which is reassuring, but so many fantastic speakers have submitted to speak that there is fierce competition.</p>
<p>This year, the session selection committee is trying something new and has requested input on the submitted abstracts.  I strongly encourage you to take a few minutes and vote for abstracts that appeal to you in the <a href="http://www.sqlpass.org/summit/2011/UserLogin.aspx?returnurl=%2fsummit%2f2011%2fSpeakers%2fSessionPreferencing.aspx%3fp%3d62%26preferred%3dFalse" target="_blank">PASS Summit 2011 Session Preference Survey</a>.  You can vote even if you might not be able to attend the conference&#8230; all that you need is an account on the <a href="http://www.sqlpass.org/" target="_blank">SQLPASS.org</a> web site.  If you don&#8217;t already have one, <a href="http://www.sqlpass.org/RegisterforSQLPASS.aspx?returnurl=%2fsummit%2f2011%2fSpeakers%2fSessionPreferencing.aspx%3fp%3d62%26preferred%3dFalse" target="_blank">registration</a> is easy and free.</p>
<p>If you have attended any of my presentations and enjoyed them/learned from them, I would greatly appreciate the support of voting for some of my sessions.  I submitted the maximum of four abstracts, but I would prefer to deliver either of my &#8220;cookbook&#8221; presentations:</p>
<ul>
<li>
                <a href="/technical-presentations/powershellcookbook/" target="_blank">A PowerShell Cookbook for DBAs</a></p>
<ul>
<li>
                            I have been delivering this presentation since <a href="http://sqlsaturday.com/22/eventhome.aspx" target="_blank">SQLSaturday #22</a> on 2010-06-05
                        </li>
<li>
                            As a production/escalation DBA, I use <a href="http://technet.microsoft.com/en-us/scriptcenter/dd742419.aspx" target="_blank">PowerShell</a> more than any other single program, <span style="font-style:italic;">especially</span> when interacting with <a href="http://www.microsoft.com/sqlserver/en/us/default.aspx" target="_blank">SQL Server</a>
                        </li>
<li>
                            My goal is to convince fellow DBAs to try PowerShell by showing a variety of ways that PowerShell makes our jobs easier and by providing attendees with a collection of ready-to-use scripts for getting started
                        </li>
</ul>
</li>
<li>
                An XQuery Cookbook for DBAs</p>
<ul>
<li>
                            This is a new presentation that is under development.  I will probably deliver it for the first time at the July meeting of the <a href="http://fwssug.org/" target="_blank">Fort Worth SQL Server Users Group</a>
                        </li>
<li>
                            A lot of valuable diagnostic data is exposed as <a href="http://en.wikipedia.org/wiki/XML" target="_blank">XML</a> these days
                        </li>
<li>
                            I have written many <a href="http://en.wikipedia.org/wiki/Transact-SQL" target="_blank">T-SQL</a>/<a href="http://en.wikipedia.org/wiki/XQuery" target="_blank">XQuery</a> scripts to analyze and manipulate the data, but I would not describe the experience as being pleasant
                        </li>
<li>
                            I would like to give other DBAs these scripts, along with a little bit of background understanding, so that they can access this very powerful meta data without the many hours of frustration in developing the scripts
                        </li>
<li>
                            Some of the &#8220;recipes&#8221; included in the presentation will work with the following data sets:</p>
<ul>
<li>
                                        <a href="http://msdn.microsoft.com/en-us/library/ms190989.aspx" target="_blank">DDL trigger</a> event data
                                    </li>
<li>
                                        <a href="http://msdn.microsoft.com/en-us/library/ms188246.aspx" target="_blank">Deadlock graphs</a>
                                    </li>
<li>
                                        <a href="http://msdn.microsoft.com/en-us/library/bb630354.aspx" target="_blank">Extended Events</a> payloads
                                    </li>
<li>
                                        Output from the <a href="http://pal.codeplex.com/" target="_blank">Performance Analysis of Logs (PAL) Tool</a>
                                    </li>
<li>
                                        The <a href="http://msdn.microsoft.com/en-us/library/dd672789(SQL.100).aspx" target="_blank">[sys].[dm_os_ring_buffers]</a> DMV&#8217;s contents
                                    </li>
<li>
                                        <a href="http://msdn.microsoft.com/en-us/library/aa385780%28VS.85%29.aspx" target="_blank">Windows event logs</a>
                                    </li>
<li>
                                        <a href="http://msdn.microsoft.com/en-us/library/ms190233.aspx" target="_blank">XML statistics profiles</a> (query plans)
                                    </li>
</ul>
</li>
</ul>
</li>
</ul>
<p><span style="font-weight:bold;">Note:</span> The deadline for voting is tomorrow, so please do so as soon as possible!</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/tnbarkhouse.wordpress.com/274/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/tnbarkhouse.wordpress.com/274/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/tnbarkhouse.wordpress.com/274/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/tnbarkhouse.wordpress.com/274/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/tnbarkhouse.wordpress.com/274/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/tnbarkhouse.wordpress.com/274/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/tnbarkhouse.wordpress.com/274/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/tnbarkhouse.wordpress.com/274/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/tnbarkhouse.wordpress.com/274/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/tnbarkhouse.wordpress.com/274/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/tnbarkhouse.wordpress.com/274/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/tnbarkhouse.wordpress.com/274/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/tnbarkhouse.wordpress.com/274/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/tnbarkhouse.wordpress.com/274/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=sqlserversleuth.com&amp;blog=6775699&amp;post=274&amp;subd=tnbarkhouse&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://sqlserversleuth.com/2011/05/19/please-vote-for-pass-summit-2011-sessions/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/a662186ae400e1e95ffca05d7b474fd7?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">tnbarkhouse</media:title>
		</media:content>
	</item>
		<item>
		<title>Code snippet &#8211; Reestablishing the backup log chain with PowerShell</title>
		<link>http://sqlserversleuth.com/2011/05/19/code-snippet-reestablishing-the-backup-log-chain-with-powershell/</link>
		<comments>http://sqlserversleuth.com/2011/05/19/code-snippet-reestablishing-the-backup-log-chain-with-powershell/#comments</comments>
		<pubDate>Thu, 19 May 2011 05:20:18 +0000</pubDate>
		<dc:creator>tnbarkhouse</dc:creator>
				<category><![CDATA[PowerShell]]></category>
		<category><![CDATA[SQL Server]]></category>
		<category><![CDATA[automation]]></category>
		<category><![CDATA[backup]]></category>
		<category><![CDATA[bad practices]]></category>
		<category><![CDATA[catalog views]]></category>
		<category><![CDATA[full recovery model]]></category>
		<category><![CDATA[shoulders of giants]]></category>
		<category><![CDATA[snippet]]></category>
		<category><![CDATA[Transact-SQL]]></category>

		<guid isPermaLink="false">http://sqlserversleuth.com/?p=267</guid>
		<description><![CDATA[We have a certain customer that has an incredible fondness for undermining the restorability of their databases. Almost all of their databases are in the full recovery model and all-too-frequently the customer will start backing up transaction logs with the &#8230; <a href="http://sqlserversleuth.com/2011/05/19/code-snippet-reestablishing-the-backup-log-chain-with-powershell/">Continue reading <span class="meta-nav">&#8594;</span></a><img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=sqlserversleuth.com&amp;blog=6775699&amp;post=267&amp;subd=tnbarkhouse&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>We have a certain customer that has an incredible fondness for undermining the restorability of their databases.  Almost all of their databases are in the <a href="http://msdn.microsoft.com/en-us/library/ms189275.aspx" target="_blank">full recovery model</a> and all-too-frequently the customer will start backing up transaction logs with the dreaded <a href="http://msdn.microsoft.com/en-us/library/ms186865%28SQL.90%29.aspx" target="_blank">NO_LOG</a> option, which destroys the <a href="http://technet.microsoft.com/en-us/magazine/gg132708.aspx" target="_blank">transaction log backup chain</a>:</p>
<pre style="color:red;margin-left:15px;">Msg 4214, Level 16, State 1, Line 1
BACKUP LOG cannot be performed because there is no current database backup.
Msg 3013, Level 16, State 1, Line 1
BACKUP LOG is terminating abnormally.</pre>
<p>In a future blog post, I will go into why users resort to this bad practice and what they should be doing instead.</p>
<p>This solution is based on a great <a href="http://sqlblog.com/blogs/kalen_delaney/archive/2008/11/30/when-is-full-recovery-not-really-full-recovery.aspx" target="_blank">blog post</a> from Kalen Delaney (<a href="http://sqlblog.com/blogs/kalen_delaney/" target="_blank">blog</a>, <a href="http://twitter.com/#!/sqlqueen" target="_blank">Twitter</a>), that showed how the <a href="http://msdn.microsoft.com/en-us/library/ms178575.aspx" target="_blank">[sys].[database_recovery_status]</a> catalog view can reveal databases suffering from this problem, using a query like so:</p>
<pre style="margin-left:15px;">SELECT DB_Name([database_id]) AS [DatabaseName]
FROM [sys].[database_recovery_status]
WHERE (
    ([last_log_backup_lsn] IS NULL)
    AND
    (Cast(DatabasePropertyEx(DB_Name([database_id]), 'Recovery') AS NVarChar(16)) = N'FULL')
    AND
    (Cast(DatabasePropertyEx(DB_Name([database_id]), 'Status') AS NVarChar(16)) = N'ONLINE')
)
ORDER BY [DatabaseName] ASC;</pre>
<p>The following <a href="http://technet.microsoft.com/en-us/scriptcenter/dd742419.aspx" target="_blank">PowerShell</a> function uses the query to retrieve a list of problematic databases and then automatically backs up each one:</p>
<pre style="margin-left:15px;">Function Repair-LogBackupChain (
    [String]$ServerName = $(Throw (New-Object -TypeName 'System.ArgumentNullException' -ArgumentList '$ServerName')),
    [String]$BackupDirectoryPath = $(Throw (New-Object -TypeName 'System.ArgumentNullException' -ArgumentList '$BackupDirectoryPath')),
    [String]$OutputDirectoryPath = $(Throw (New-Object -TypeName 'System.ArgumentNullException' -ArgumentList '$OutputDirectoryPath'))
) {
    [Int]$BackedUpDatabaseCount = 0;
    [String]$BackupFilePath = '';
    [String]$DatabaseName = '';
    [String]$ErrorMessage = '';
    [String]$OutputFilePath = '';
    [String]$Query = "SET NOCOUNT ON; SELECT DB_Name([database_id]) AS [DatabaseName] FROM [sys].[database_recovery_status] WHERE (([last_log_backup_lsn] IS NULL) AND (Cast(DatabasePropertyEx(DB_Name([database_id]), 'Recovery') AS NVarChar(16)) = N'FULL') AND (Cast(DatabasePropertyEx(DB_Name([database_id]), 'Status') AS NVarChar(16)) = N'ONLINE')) ORDER BY [DatabaseName] ASC;";
    [String]$TSQLCode = '';

    #   Create the necessary directories, if they don't already exist.
    $BackupDirectoryPath = Add-Directory -Path $BackupDirectoryPath;
    $OutputDirectoryPath = Add-Directory -Path $OutputDirectoryPath;

    #   Lookup the names of the databases, in the full recovery model, that
    #   lack an intact transaction log backup chain.
    [String[]]$DatabaseNames = @(&amp; 'SQLCmd.exe' -E -S $ServerName -d 'tempdb' -Q $Query -b -h-1 -W);
    $DatabaseNames | Write-Debug;

    #   Verify that the list of databases was successfully retrieved.
    If ((Get-Item -Path Variable:'LastExitCode').Value -eq 0) {
        #   Iterate through the databases that need backups.
        $DatabaseNames | ForEach-Object {
            $DatabaseName = $_;
            Write-Host "Backing up the [$($DatabaseName)] database..." -ForegroundColor 'Cyan';

            $OutputFilePath = "$($OutputDirectoryPath)$(Get-EscapedFileNameComponent -FileNameComponent $ServerName),Backup database,$(Get-EscapedFileNameComponent -FileNameComponent $DatabaseName),$([DateTime]::Now.ToString('yyyyMMddTHHmmssfff')).out";
            Write-Debug "`$OutputFilePath = `"$($OutputFilePath)`"";

            #   Construct the name of the backup file.
            $BackupFilePath = [String]::Format(
                '{0}{1}_{2}_{3}.bak',
                $BackupDirectoryPath,
                (Get-EscapedFileNameComponent -FileNameComponent $ServerName),
                (Get-EscapedFileNameComponent -FileNameComponent $DatabaseName),
                ([DateTime]::Now.ToString('yyyyMMddTHHmmssfff'))
            );

            #   Generate the T-SQL for backing up the database.
            $TSQLCode = [String]::Format(
                "BACKUP DATABASE [{0}] TO DISK = N'{1}';",
                $DatabaseName,
                $BackupFilePath
            );
            Write-Debug "`$TSQLCode = `"$($TSQLCode)`"";

            #   Backup the database.
            &amp; 'SQLCmd.exe' -E -S $ServerName -d 'tempdb' -Q $TSQLCode -o $OutputFilePath -b;

            If (Test-Path -LiteralPath $BackupFilePath -PathType 'Leaf') {
                $BackedUpDatabaseCount++;
            }
            Else {
                $ErrorMessage = "There was a problem backing up the [$($DatabaseName)] database.";
                Throw (New-Object -TypeName 'System.InvalidOperationException' -ArgumentList $ErrorMessage);
            }
        }
    }
    Else {
        $ErrorMessage = [String]::Format(
            "There was a problem querying the [sys].[database_recovery_status] catalog view:`r`n{0}",
            (
                [String]::Join(
                    "`r`n",
                    $DatabaseNames
                )
            )
        );
        Throw (New-Object -TypeName 'System.InvalidOperationException' -ArgumentList $ErrorMessage);
    }

    Write-Host "A total of $($BackedUpDatabaseCount) database(s) was/were backed up." -ForegroundColor 'Green';

    Return;
}</pre>
<p>Here&#8217;s an example of using the function:</p>
<pre style="margin-left:15px;">Repair-LogBackupChain -ServerName 'DatabaseServer01\InstanceA' -BackupDirectoryPath 'C:\Temp\' -OutputDirectoryPath 'C:\Temp\';</pre>
<p><span style="font-weight:bold;">Note:</span> The code snippet is dependent on two functions that are included in the download for my <a href="/technical-presentations/powershellcookbook/" target="_blank">PowerShell cookbook</a> presentation, <span style="font-style:italic;">Add-Directory</span> and <span style="font-style:italic;">Get-EscapedFileNameComponent</span>.</p>
<p>Maybe by the time that I write the follow-up blog post, I will have received permission to break the customer of this nasty habit (using a <a href="http://www.sqlskills.com/BLOGS/PAUL/post/BACKUP-LOG-WITH-NO_LOG-use-abuse-and-undocumented-trace-flags-to-stop-it.aspx" target="_blank">tip</a> from Paul Randal (<a href="http://www.sqlskills.com/blogs/Paul/" target="_blank">blog</a>, <a href="http://twitter.com/#!/PaulRandal" target="_blank">Twitter</a>)).</p>
<p>Hopefully this PowerShell snippet will save you as much time as it has for me!</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/tnbarkhouse.wordpress.com/267/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/tnbarkhouse.wordpress.com/267/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/tnbarkhouse.wordpress.com/267/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/tnbarkhouse.wordpress.com/267/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/tnbarkhouse.wordpress.com/267/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/tnbarkhouse.wordpress.com/267/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/tnbarkhouse.wordpress.com/267/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/tnbarkhouse.wordpress.com/267/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/tnbarkhouse.wordpress.com/267/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/tnbarkhouse.wordpress.com/267/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/tnbarkhouse.wordpress.com/267/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/tnbarkhouse.wordpress.com/267/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/tnbarkhouse.wordpress.com/267/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/tnbarkhouse.wordpress.com/267/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=sqlserversleuth.com&amp;blog=6775699&amp;post=267&amp;subd=tnbarkhouse&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://sqlserversleuth.com/2011/05/19/code-snippet-reestablishing-the-backup-log-chain-with-powershell/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/a662186ae400e1e95ffca05d7b474fd7?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">tnbarkhouse</media:title>
		</media:content>
	</item>
		<item>
		<title>SQL Trace presentation materials posted</title>
		<link>http://sqlserversleuth.com/2011/04/24/sql-trace-presentation-materials-posted/</link>
		<comments>http://sqlserversleuth.com/2011/04/24/sql-trace-presentation-materials-posted/#comments</comments>
		<pubDate>Mon, 25 Apr 2011 02:20:32 +0000</pubDate>
		<dc:creator>tnbarkhouse</dc:creator>
				<category><![CDATA[SQL Server]]></category>
		<category><![CDATA[attachments]]></category>
		<category><![CDATA[Profiler]]></category>
		<category><![CDATA[speaking]]></category>
		<category><![CDATA[SQL Trace]]></category>

		<guid isPermaLink="false">http://sqlserversleuth.com/?p=261</guid>
		<description><![CDATA[I just uploaded a new set of deliverables from my SQL Trace presentation (which can be found here). Let me know if you have any questions.<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=sqlserversleuth.com&amp;blog=6775699&amp;post=261&amp;subd=tnbarkhouse&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>I just uploaded a new set of deliverables from my <a href="/technical-presentations/sqltrace/" target="_blank">SQL Trace presentation</a> (which can be found <a href="http://s3.amazonaws.com/sqlserversleuth-presentations/Presentation_AnIntroductionToProfilerAndSQLTrace_0001000300030014.zip" target="_blank">here</a>).  Let me know if you have any questions.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/tnbarkhouse.wordpress.com/261/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/tnbarkhouse.wordpress.com/261/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/tnbarkhouse.wordpress.com/261/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/tnbarkhouse.wordpress.com/261/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/tnbarkhouse.wordpress.com/261/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/tnbarkhouse.wordpress.com/261/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/tnbarkhouse.wordpress.com/261/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/tnbarkhouse.wordpress.com/261/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/tnbarkhouse.wordpress.com/261/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/tnbarkhouse.wordpress.com/261/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/tnbarkhouse.wordpress.com/261/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/tnbarkhouse.wordpress.com/261/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/tnbarkhouse.wordpress.com/261/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/tnbarkhouse.wordpress.com/261/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=sqlserversleuth.com&amp;blog=6775699&amp;post=261&amp;subd=tnbarkhouse&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://sqlserversleuth.com/2011/04/24/sql-trace-presentation-materials-posted/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/a662186ae400e1e95ffca05d7b474fd7?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">tnbarkhouse</media:title>
		</media:content>
	</item>
		<item>
		<title>Script &#8211; Extracting XML deadlock graphs from a trace file</title>
		<link>http://sqlserversleuth.com/2011/02/24/script-extracting-xml-deadlock-graphs-from-a-trace-file/</link>
		<comments>http://sqlserversleuth.com/2011/02/24/script-extracting-xml-deadlock-graphs-from-a-trace-file/#comments</comments>
		<pubDate>Thu, 24 Feb 2011 17:04:00 +0000</pubDate>
		<dc:creator>tnbarkhouse</dc:creator>
				<category><![CDATA[PowerShell]]></category>
		<category><![CDATA[SQL Server]]></category>
		<category><![CDATA[attachments]]></category>
		<category><![CDATA[automation]]></category>
		<category><![CDATA[deadlocks]]></category>
		<category><![CDATA[Profiler]]></category>
		<category><![CDATA[script]]></category>
		<category><![CDATA[SMO]]></category>
		<category><![CDATA[SQL Trace]]></category>
		<category><![CDATA[SQLskills Immersion]]></category>
		<category><![CDATA[XML]]></category>

		<guid isPermaLink="false">http://sqlserversleuth.com/?p=254</guid>
		<description><![CDATA[Today is my fourth day of SQLskills Immersion Events training, taught by none other than Paul Randal (blog, Twitter) and Kimberly Tripp (blog, Twitter). The material and delivery have been amazing and I hope to have a chance to blog &#8230; <a href="http://sqlserversleuth.com/2011/02/24/script-extracting-xml-deadlock-graphs-from-a-trace-file/">Continue reading <span class="meta-nav">&#8594;</span></a><img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=sqlserversleuth.com&amp;blog=6775699&amp;post=254&amp;subd=tnbarkhouse&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Today is my fourth day of <a href="http://www.sqlskills.com/T_SQLskillsMasterImmersionEvents.asp" target="_blank">SQLskills Immersion Events</a> training, taught by none other than Paul Randal (<a href="http://www.sqlskills.com/blogs/Paul/" target="_blank">blog</a>, <a href="http://twitter.com/#!/PaulRandal" target="_blank">Twitter</a>) and Kimberly Tripp (<a href="http://www.sqlskills.com/blogs/Kimberly/" target="_blank">blog</a>, <a href="http://twitter.com/#!/KimberlyLTripp" target="_blank">Twitter</a>).  The material and delivery have been amazing and I hope to have a chance to blog about it this weekend.  A fellow student, Eric Humphrey (<a href="http://www.erichumphrey.com/" target="_blank">blog</a>, <a href="http://twitter.com/#!/lotsahelp" target="_blank">Twitter</a>), asked about automatically extracting <a href="http://msdn.microsoft.com/en-us/library/ms177409.aspx" target="_blank">XML deadlock graphs</a> from a <a href="http://msdn.microsoft.com/en-us/library/ms191006.aspx" target="_blank">SQL Trace</a> file.</p>
<p>I&#8217;m a big proponent of using <a href="http://msdn.microsoft.com/en-us/library/ms191443.aspx" target="_blank">server-side traces</a> for <a href="http://msdn.microsoft.com/en-us/library/ms188246.aspx" target="_blank">troubleshooting deadlocks</a>.  During my <a href="/technical-presentations/deadlocks/" target="_blank">deadlocks presentation</a>, I show how to manually extract XML deadlock graphs using <a href="http://msdn.microsoft.com/en-us/library/ms181091.aspx" target="_blank">SQL Server Profiler</a>:</p>
<p>
        <img src="http://tnbarkhouse.files.wordpress.com/2011/02/sqlserverprofiler_extractxdls.png?w=640" style="margin-left:25px;">
    </p>
<p>That works, but it&#8217;s a manual process, which is anathema to us automation adherents.</p>
<p>When processing XML deadlock graphs, I tend to:</p>
<ol>
<li>query the trace data, via the <a href="http://msdn.microsoft.com/en-us/library/ms188425.aspx" target="_blank">[sys].[fn_trace_gettable]</a> system function,</li>
<li><a href="http://msdn.microsoft.com/en-us/library/ms187928.aspx" target="_blank">cast</a> the <a href="http://msdn.microsoft.com/en-us/library/ms190762.aspx" target="_blank">[TextData]</a> value to the <a href="http://msdn.microsoft.com/en-us/library/ms187339.aspx" target="_blank">XML</a> data type, then</li>
<li>analyze the deadlocks with <a href="http://msdn.microsoft.com/en-us/library/ms189075.aspx" target="_blank">XQuery</a>.</li>
</ol>
<p>I can see the benefit of having a few loose *.XDL files, so I spent a little time writing a <a href="http://technet.microsoft.com/en-us/scriptcenter/dd742419.aspx" target="_blank">PowerShell</a> script that will automatically extract the XML deadlock graphs and save them as files.  <a href="http://s3.amazonaws.com/sqlserversleuth-blog-post-attachments/ExportXDLFromTraceFile_0001000100200008.zip" target="_blank">This zip archive</a> contains the script and sample trace files.</p>
<p>Here is an example of using the script (assuming that you extracted the files to the &#8220;C:\Temp\&#8221; directory):</p>
<pre style="margin-left:15px;">[String]$ScriptUtilityPath = 'C:\Temp\Export-XDLFromTraceFile.ps1';
[String]$OutputDirectoryPath = 'C:\Temp\';
[String]$SourceServerName = 'T-SQL001';
[String]$TraceFilePath = 'C:\Temp\DeadlockTrace_20100522T113514.trc';
&amp; $ScriptUtilityPath -TraceFilePath $TraceFilePath -OutputDirectoryPath $OutputDirectoryPath -SourceServerName $SourceServerName -FormatXML | Out-Null;</pre>
<p>Here&#8217;s another example that leverages PowerShell&#8217;s <a href="http://en.wikipedia.org/wiki/Composability" target="_blank">composable</a> nature:</p>
<pre style="margin-left:15px;">[String]$ScriptUtilityPath = 'C:\Temp\Export-XDLFromTraceFile.ps1';
[String]$OutputDirectoryPath = 'C:\Temp\';
[System.IO.FileInfo[]]$OutputFiles = @();
[String]$SourceDirectoryPath = 'C:\Temp\';
[String]$SourceServerName = 'T-SQL001';
[String]$TraceFilePath = '';
Get-ChildItem -LiteralPath $SourceDirectoryPath -Filter '*.trc' | ForEach-Object {
    $TraceFilePath = $_.FullName;
    $OutputFiles += @(&amp; $ScriptUtilityPath -TraceFilePath $TraceFilePath -OutputDirectoryPath $OutputDirectoryPath -SourceServerName $SourceServerName -FormatXML);
}
$OutputFiles | Select-Object -Property Name, @{Name='Size_bytes'; Expression={'{0:N0}' -f $_.Length}} | Format-Table -AutoSize;</pre>
<p>Let me know if this is useful to you, or if you have any suggestions to make it better.</p>
<p>NOTE: I haven&#8217;t had a chance to test the script with the SQL Server 2005 <a href="http://msdn.microsoft.com/en-us/library/ms162169.aspx" target="_blank">SQL Server Management Objects</a> (SMO) assemblies.  I suspect one or both of the following issues:</p>
<ul>
<li>Classes may reside in different assemblies—SMO has a <a href="http://msdn.microsoft.com/en-us/library/dd206977.aspx" target="_blank">less than stellar history of backward compatibility</a></li>
<li>The sample trace files were created on a SQL Server 2008 R2 instance, so they probably cannot be opened by the 9.0 tools</li>
</ul>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/tnbarkhouse.wordpress.com/254/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/tnbarkhouse.wordpress.com/254/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/tnbarkhouse.wordpress.com/254/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/tnbarkhouse.wordpress.com/254/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/tnbarkhouse.wordpress.com/254/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/tnbarkhouse.wordpress.com/254/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/tnbarkhouse.wordpress.com/254/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/tnbarkhouse.wordpress.com/254/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/tnbarkhouse.wordpress.com/254/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/tnbarkhouse.wordpress.com/254/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/tnbarkhouse.wordpress.com/254/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/tnbarkhouse.wordpress.com/254/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/tnbarkhouse.wordpress.com/254/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/tnbarkhouse.wordpress.com/254/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=sqlserversleuth.com&amp;blog=6775699&amp;post=254&amp;subd=tnbarkhouse&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://sqlserversleuth.com/2011/02/24/script-extracting-xml-deadlock-graphs-from-a-trace-file/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/a662186ae400e1e95ffca05d7b474fd7?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">tnbarkhouse</media:title>
		</media:content>

		<media:content url="http://tnbarkhouse.files.wordpress.com/2011/02/sqlserverprofiler_extractxdls.png" medium="image" />
	</item>
	</channel>
</rss>
