<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Clay Lenhart's Blog &#187; SQL Server Administration</title>
	<atom:link href="http://clay.lenharts.net/blog/tag/sql-server-administration/feed/" rel="self" type="application/rss+xml" />
	<link>http://clay.lenharts.net/blog</link>
	<description>A blog on .Net and SQL Server</description>
	<lastBuildDate>Tue, 31 Oct 2017 10:34:08 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=4.2.2</generator>
	<item>
		<title>SQL Server Compressed Backup v1.2 Released</title>
		<link>http://clay.lenharts.net/blog/2009/11/23/sql-server-compressed-backup-v12-released/</link>
		<comments>http://clay.lenharts.net/blog/2009/11/23/sql-server-compressed-backup-v12-released/#comments</comments>
		<pubDate>Mon, 23 Nov 2009 14:44:22 +0000</pubDate>
		<dc:creator><![CDATA[Clay Lenhart]]></dc:creator>
				<category><![CDATA[MSSQL Compressed Backup]]></category>
		<category><![CDATA[SQL Server Administration]]></category>

		<guid isPermaLink="false">http://clay.lenharts.net/blog/?p=126</guid>
		<description><![CDATA[I've just released version 1.2-20091123 of SQL Server Compressed Backup.  SQL Server Compressed Backup will back up a SQL Server database to a compressed file, using either gzip, zip and bzip2.  The new features are: <a href="http://clay.lenharts.net/blog/2009/11/23/sql-server-compressed-backup-v12-released/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
				<content:encoded><![CDATA[<p>I&#8217;ve just released version 1.2-20091123 of <a href="https://sourceforge.net/projects/mssqlcompressed/">SQL Server Compressed Backup</a> which can be <a href="https://sourceforge.net/projects/mssqlcompressed/files/MSSQLCompressedBackup/1.2-20091123/MSSQLCompressedBackup-1.2-20091123.zip/download">downloaded here</a>.  </p>
<p>SQL Server Compressed Backup will back up SQL Server databases using either gzip, zip or bzip2 compression.</p>
<p>The new features are:<br />
<span id="more-126"></span></p>
<ul>
<li>Fixed the encoding problem by removing “\s”, “\p” and “\\” since they are commonly used in file paths and replacing them with “;;” to mean “;”. Looking at the command line options, it is only necessary to encode the semicolon, so “;;” is the only encoding the command line does.</li>
<li>Added a feature I’ve personally wanted: progress updates and an estimated time until completion. It is more verbose at the beginning (every few seconds), then slows down. After an hour of backing up, updates are only once every 24 minutes.</li>
<li>Worked on the BlockSize and BufferCount request. I’m not keen on implementing BlockSize. I’d like to hear someone explain how they take advantage of it. My understanding is that BlockSize is only for writing to devices (tapes and CD-ROMs — not files on a CD-ROM though), so it doesn’t seem appropriate for backing up to files. BufferCount and MaxTransferSize seem like reasonable options to request, so these are now available.</li>
</ol>
]]></content:encoded>
			<wfw:commentRss>http://clay.lenharts.net/blog/2009/11/23/sql-server-compressed-backup-v12-released/feed/</wfw:commentRss>
		<slash:comments>129</slash:comments>
		</item>
		<item>
		<title>Execution Plan of Frequent Queries</title>
		<link>http://clay.lenharts.net/blog/2009/05/29/execution-plan-of-frequent-queries/</link>
		<comments>http://clay.lenharts.net/blog/2009/05/29/execution-plan-of-frequent-queries/#comments</comments>
		<pubDate>Fri, 29 May 2009 19:03:42 +0000</pubDate>
		<dc:creator><![CDATA[Clay Lenhart]]></dc:creator>
				<category><![CDATA[SQL Server Administration]]></category>
		<category><![CDATA[dynamic management views]]></category>
		<category><![CDATA[execution plan]]></category>
		<category><![CDATA[SQL Server 2005]]></category>
		<category><![CDATA[SQL Server 2008]]></category>
		<category><![CDATA[SQL Server Engine]]></category>

		<guid isPermaLink="false">http://clay.lenharts.net/blog/?p=110</guid>
		<description><![CDATA[Bill Galashan, DBA of bet365 sent over the following query that lists the execution plan of the 10 most frequently executed queries. <a href="http://clay.lenharts.net/blog/2009/05/29/execution-plan-of-frequent-queries/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
				<content:encoded><![CDATA[<p>Bill Galashan, DBA of <a href="http://www.bet365.com/">bet365</a> sent over the following query that lists the execution plan of the 10 most frequently executed queries.</p>
<p>He writes:</p>
<blockquote><p>We got into this due to different query plans coming from a VB or a web app than what was seen when running the same query from Management Studio. Eventually tracked this down to a difference in the set options predominatley whether Arithabort was on or off. </p></blockquote>
<p>Read more to see his query.<span id="more-110"></span></p>
<p>Click here to <a href="http://clay.lenharts.net/blog/2008/04/13/cached-execution-plans-in-sql-server/">see the execution plan of currently running queries</a>. </p>
<pre class="brush: sql; title: ; notranslate">
SELECT TOP 10 creation_time, last_execution_time,  last_worker_time / 1000 as [Last Worker Time (ms)] ,min_worker_time / 1000 as [Min Worker Time (ms)], 
      max_worker_time / 1000 as [Max Worker Time (ms)],
    total_worker_time/execution_count/1000 AS [Avg Worker Time (ms)],
    execution_count, 
    SUBSTRING(st.text, (qs.statement_start_offset/2) + 1,
    ((CASE statement_end_offset 
        WHEN -1 THEN DATALENGTH(st.text)
        ELSE qs.statement_end_offset 
        END 
            - qs.statement_start_offset)/2) + 1) as statement_text,plan_generation_num ,query_plan, Plan_handle
FROM sys.dm_exec_query_stats as qs
CROSS APPLY sys.dm_exec_sql_text(qs.sql_handle) as st
CROSS APPLY sys.dm_exec_query_plan(qs.plan_handle)
-- where st.text like '%proc name to be searched for%'
ORDER BY execution_count DESC;
</pre>
<pre class="brush: sql; title: ; notranslate">
--- Determine options used at run time

select  * from sys.syscacheobjects with (nolock) where sql like '%proc to be searched for%' and objtype='proc'


select dbo.fn_setopts(249)

/*
 This contains a bitmap containing the SET options relevant to each cached plan for a proc.
The following function can be used to decipher this bitmask:
*/

 

create function dbo.fn_setopts(@setopts int)
returns nvarchar(4000)

as
begin

declare @s nvarchar(4000)
select @s='Options: '
if @setopts &amp;amp;amp;amp;amp; 1    &gt; 0 select @s = @s + N'ANSI_PADDING, ' 
if @setopts &amp;amp;amp;amp;amp; 2    &gt; 0 select @s = @s + N'max degree of parallelism, '
if @setopts &amp;amp;amp;amp;amp; 4    &gt; 0 select @s = @s + N'FORCEPLAN, ' 
if @setopts &amp;amp;amp;amp;amp; 8    &gt; 0 select @s = @s + N'CONCAT_NULL_YIELDS_NULL, '
if @setopts &amp;amp;amp;amp;amp; 16   &gt; 0 select @s = @s + N'ANSI_WARNINGS, '
if @setopts &amp;amp;amp;amp;amp; 32   &gt; 0 select @s = @s + N'ANSI_NULLS, '
if @setopts &amp;amp;amp;amp;amp; 64   &gt; 0 select @s = @s + N'QUOTED_IDENTIFIER, '
if @setopts &amp;amp;amp;amp;amp; 128  &gt; 0 select @s = @s + N'ANSI_NULL_DFLT_ON, '
if @setopts &amp;amp;amp;amp;amp; 256  &gt; 0 select @s = @s + N'ANSI_NULL_DFLT_OFF, '
if @setopts &amp;amp;amp;amp;amp; 512  &gt; 0 select @s = @s + N'NO_BROWSETABLE, '
if @setopts &amp;amp;amp;amp;amp; 1024 &gt; 0 select @s = @s + N'TriggerOneRow, '
if @setopts &amp;amp;amp;amp;amp; 2048 &gt; 0 select @s = @s + N'ResyncQuery, '
if @setopts &amp;amp;amp;amp;amp; 4096 &gt; 0 select @s = @s + N'ARITHABORT, '
if @setopts &amp;amp;amp;amp;amp; 8192 &gt; 0 select @s = @s + N'NUMERIC_ROUNDABORT, ' 

return @s

end
</pre>
]]></content:encoded>
			<wfw:commentRss>http://clay.lenharts.net/blog/2009/05/29/execution-plan-of-frequent-queries/feed/</wfw:commentRss>
		<slash:comments>28</slash:comments>
		</item>
		<item>
		<title>MSSQL Compressed Backup 1.0 Released</title>
		<link>http://clay.lenharts.net/blog/2008/08/24/mssql-compressed-backup-10-released/</link>
		<comments>http://clay.lenharts.net/blog/2008/08/24/mssql-compressed-backup-10-released/#comments</comments>
		<pubDate>Sun, 24 Aug 2008 21:40:10 +0000</pubDate>
		<dc:creator><![CDATA[Clay Lenhart]]></dc:creator>
				<category><![CDATA[MSSQL Compressed Backup]]></category>
		<category><![CDATA[SQL Server Administration]]></category>

		<guid isPermaLink="false">http://clay.lenharts.net/blog/?p=39</guid>
		<description><![CDATA[I&#8217;ve just released version 1.0 of MSSQL Compressed Backup.  This is a command line utility that allows you to backup or restore your SQL Server 2005 databases to/from compressed files such as zip, bzip2, or gzip. http://mssqlcompressed.sourceforge.net/]]></description>
				<content:encoded><![CDATA[<p>I&#8217;ve just released version 1.0 of MSSQL Compressed Backup.  This is a command line utility that allows you to backup or restore your SQL Server 2005 databases to/from compressed files such as zip, bzip2, or gzip.</p>
<p><a href="http://mssqlcompressed.sourceforge.net/">http://mssqlcompressed.sourceforge.net/</a></p>
]]></content:encoded>
			<wfw:commentRss>http://clay.lenharts.net/blog/2008/08/24/mssql-compressed-backup-10-released/feed/</wfw:commentRss>
		<slash:comments>16</slash:comments>
		</item>
		<item>
		<title>Renaming a SQL Server machine</title>
		<link>http://clay.lenharts.net/blog/2008/08/08/renaming-a-sql-server-machine/</link>
		<comments>http://clay.lenharts.net/blog/2008/08/08/renaming-a-sql-server-machine/#comments</comments>
		<pubDate>Fri, 08 Aug 2008 20:48:14 +0000</pubDate>
		<dc:creator><![CDATA[Clay Lenhart]]></dc:creator>
				<category><![CDATA[SQL Server Administration]]></category>

		<guid isPermaLink="false">http://clay.lenharts.net/blog/?p=38</guid>
		<description><![CDATA[Below are a collection of links on how to rename a SQL Server server. Rename the SQL Server engine. This describes how to run Rename SQL Server Reporting Services server. This describes how to update a config file with the &#8230; <a href="http://clay.lenharts.net/blog/2008/08/08/renaming-a-sql-server-machine/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
				<content:encoded><![CDATA[<p>Below are a collection of links on how to rename a SQL Server server.</p>
<p><a href="http://support.microsoft.com/kb/303774">Rename the SQL Server engine</a>. This describes how to run</p>
<pre class="brush: sql; title: ; notranslate">sp_dropserver 'old_name'
go
sp_addserver 'new_name', 'local'
go</pre>
<p><a href="http://msdn.microsoft.com/en-us/library/ms345235.aspx">Rename SQL Server Reporting Services server</a>. This describes how to update a config file with the new server name.</p>
<p><a href="http://www.eggheadcafe.com/software/aspnet/29873173/error-installing-sql-2005.aspx">Correct an issue with SQL Server SP2 and Sysprep</a>.  This is needed when you run sysprep to rename the machine. The short of it is you will need to delete some registry entries.</p>
]]></content:encoded>
			<wfw:commentRss>http://clay.lenharts.net/blog/2008/08/08/renaming-a-sql-server-machine/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>SQL Server 2005 Compressed Backup</title>
		<link>http://clay.lenharts.net/blog/2008/06/14/sql-server-2005-compressed-backup/</link>
		<comments>http://clay.lenharts.net/blog/2008/06/14/sql-server-2005-compressed-backup/#comments</comments>
		<pubDate>Sat, 14 Jun 2008 12:21:22 +0000</pubDate>
		<dc:creator><![CDATA[Clay Lenhart]]></dc:creator>
				<category><![CDATA[MSSQL Compressed Backup]]></category>
		<category><![CDATA[SQL Server Administration]]></category>

		<guid isPermaLink="false">http://clay.lenharts.net/blog/?p=37</guid>
		<description><![CDATA[I've been working on a way to backup a SQL Server 2005 database to a compressed file recently, but without using temporary files, so I wrote MSSQL Compressed Backup. <a href="http://clay.lenharts.net/blog/2008/06/14/sql-server-2005-compressed-backup/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
				<content:encoded><![CDATA[<p>I&#8217;ve been working on a way to backup SQL Server 2005 databases to a compressed file recently, but without using temporary files.  I recently found that it is actually pretty easy.  SQL Server has an <a href="http://www.microsoft.com/downloads/details.aspx?familyid=416f8a51-65a3-4e8e-a4c8-adfe15e850fc&amp;displaylang=en">interface for creating a virtual backup device</a> so that the data is pumped to your application, not a real device.  Once the application has the data, it can compress it, encrypt it, or do whatever it likes.  Maybe DBAs would like to save the data to an FTP server.  There are so many options.</p>
<p>The application I wrote is called <a href="http://mssqlcompressed.sourceforge.net/">MSQL Compressed Backup</a> which you can find on Sourceforge.  It is currently in beta, and I don&#8217;t plan to release a 1.0 version for awhile until it has had some testing by other people.  If you are interested in it, please download a copy and give it a try.</p>
<p>Documentation is currently lacking, but here are a couple of examples.  I think they are self explanatory.</p>
<ul>
<li>msbp.exe backup [model] gzip file:///c:\model.bak.gz</li>
<li>msbp.exe restore file:///c:\model.bak.gz gzip [model]<br />
Here, gzip knows to uncompress since it is in &#8220;restore&#8221; mode.</li>
<li>msbp.exe backup [model] bzip2(level=5) file:///c:\model.bak.bz2<br />
Each plugin in the pipeline can have parameters.</li>
<li>msbp.exe backup [model] rate(ratemb=5.0) bzip2(level=5) file:///c:\model.bak.bz2<br />
You can have any number of plugins in the pipeline.  The rate plugin limits the impact of a backup on your server by restricting the speed of the backup (or restore).</li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://clay.lenharts.net/blog/2008/06/14/sql-server-2005-compressed-backup/feed/</wfw:commentRss>
		<slash:comments>91</slash:comments>
		</item>
		<item>
		<title>Cached Execution Plans in SQL Server</title>
		<link>http://clay.lenharts.net/blog/2008/04/13/cached-execution-plans-in-sql-server/</link>
		<comments>http://clay.lenharts.net/blog/2008/04/13/cached-execution-plans-in-sql-server/#comments</comments>
		<pubDate>Sun, 13 Apr 2008 20:38:04 +0000</pubDate>
		<dc:creator><![CDATA[Clay Lenhart]]></dc:creator>
				<category><![CDATA[SQL Server Administration]]></category>
		<category><![CDATA[dynamic management views]]></category>
		<category><![CDATA[execution plan]]></category>
		<category><![CDATA[performance]]></category>
		<category><![CDATA[SQL Server 2005]]></category>
		<category><![CDATA[SQL Server 2008]]></category>
		<category><![CDATA[SQL Server Engine]]></category>

		<guid isPermaLink="false">http://clay.lenharts.net/blog/?p=35</guid>
		<description><![CDATA[This blog entry describes how you can get the SQL Server execution plan of any running statement and display the graphical representation in Enterprise Manager. <a href="http://clay.lenharts.net/blog/2008/04/13/cached-execution-plans-in-sql-server/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
				<content:encoded><![CDATA[<p><em>I have been working on a performance problem recently, so you might see several blog entries with information that help me.  Hopefully they will help you.</em></p>
<p>Update: Here is a query to get the <a href="http://clay.lenharts.net/blog/2009/05/29/execution-plan-of-frequent-queries/">execution plan of the most frequently used queries</a>.</p>
<p>Getting the SQL Server execution plan from a production can be difficult, since you are not running the code within Enterprise Manager.  You can still get the execution plan of any running statement and display the graphical representation in Enterprise Manager.<span id="more-35"></span></p>
<p>If your script is currently running, you can <a href="http://blogs.technet.com/vipulshah/archive/2007/09/24/notes-taken-during-pass-session-plan-cache-analysis-in-sql-server-2005.aspx">lookup its execution plan</a> in the plan cache.  The steps are:</p>
<ol>
<li>Run a query to get the the plan_handle of currently running code</li>
<li>Lookup the execution plan for the plan_handle.</li>
</ol>
<p>The first query is:</p>
<pre class="brush: sql; title: ; notranslate">SELECT
sder.session_id AS [SPID],
sder.sql_handle as [SQL_Handle],
sder.plan_handle as [PLAN_Handle],
sdes.login_name AS [Login],
sd.name AS [DBName],
sder.start_time AS [Start Time],
sder.status AS [Status],
sder.command AS [Command],
sdet.text AS [SQL Text],
sder.percent_complete AS [Pct Cmplt],
sder.estimated_completion_time AS [Est Cmplt Time],
sder.wait_type AS [Wait],
sder.wait_time AS [Wait Time],
sder.last_wait_type AS [Last Wait],
sder.cpu_time AS [CPU Time],
sder.total_elapsed_time AS [Total Elpsd Time],
sder.reads AS [Reads],
sder.writes AS [Writes],
sder.logical_reads AS [Logical Reads]
FROM
sys.dm_exec_Requests sder
CROSS APPLY sys.dm_exec_sql_text(sql_handle) AS sdet
JOIN sys.dm_exec_sessions sdes on sder.session_id = sdes.session_id
JOIN sys.databases sd on sder.database_id = sd.database_id
WHERE
sder.session_id &lt;&gt; @@SPID and sder.session_id &gt; 50</pre>
<p>The second query is:</p>
<pre class="brush: sql; title: ; notranslate">SELECT * FROM sys.dm_exec_query_plan ( &lt;PLAN_Handle&gt; )
--here &lt;PLAN_Handle&gt; is supplied based on
--the results from the first query.</pre>
<p>This gives you the XML execution plan that you can copy and paste into notepad, save it with a *.sqlplan extension, and double click on the file to view the graphical version of the execution plan.</p>
]]></content:encoded>
			<wfw:commentRss>http://clay.lenharts.net/blog/2008/04/13/cached-execution-plans-in-sql-server/feed/</wfw:commentRss>
		<slash:comments>37</slash:comments>
		</item>
	</channel>
</rss>
