<?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>Sql Insight</title>
	<atom:link href="http://sqlinsight.net/blog/?feed=rss2" rel="self" type="application/rss+xml" />
	<link>http://sqlinsight.net/blog</link>
	<description>A place for SQL insight</description>
	<lastBuildDate>Fri, 18 May 2012 11:11:55 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.2</generator>
		<item>
		<title>Out of disk space&#8230;Log file grown too big?</title>
		<link>http://sqlinsight.net/blog/?p=264</link>
		<comments>http://sqlinsight.net/blog/?p=264#comments</comments>
		<pubDate>Fri, 18 May 2012 02:59:25 +0000</pubDate>
		<dc:creator>Steve Schneider</dc:creator>
				<category><![CDATA[SQL 2005]]></category>
		<category><![CDATA[SQL 2008]]></category>
		<category><![CDATA[SQL Administration]]></category>
		<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://sqlinsight.net/blog/?p=264</guid>
		<description><![CDATA[It&#8217;s early in the morning, and you&#8217;ve got disk space problems&#8230; log file, right?  Yep.   OK, we need a script that will tell us what we need to know ASAP.  Since i experienced this issue multiple times&#8230;and since they always &#8230; <a href="http://sqlinsight.net/blog/?p=264">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>It&#8217;s early in the morning, and you&#8217;ve got disk space problems&#8230; log file, right?  Yep.   OK, we need a script that will tell us what we need to know ASAP.  Since i experienced this issue multiple times&#8230;and since they always happened on Sunday morning&#8230;just before i was going to church (how much more inconvenient can it get?)&#8230;i created just such a script.  Using two CTE&#8217;s i first gather the information i need about the database data files, and then the database log files.  Since there can be multiple physical files for either type, i max and sum the needed values before grouping.  Then, i combine that data with sys.database information.  The result gives me almost all i need to know in a single picture&#8230;i&#8217;m ready then, with a simple &#8220;<span style="color: #0000ff;">xp_fixeddrives</span>&#8221; to get straight to fixing things.<span id="more-264"></span><br />
<code><span style="color: #0000ff;">with</span><br />
mdf <span style="color: #0000ff;">as</span><br />
<span style="color: #0000ff;"> (   SELECT</span> DB_NAME(database_id) <span style="color: #0000ff;">AS</span> DatabaseName, Max(Name) <span style="color: #0000ff;">AS</span> Logical_Name,<br />
<span style="color: #0000ff;">     Max</span>(Physical_Name) as Physical_name,<br />
<span style="color: #0000ff;">     Sum</span>((size*8)/1024) SizeMB<br />
<span style="color: #0000ff;">     FROM</span> sys.master_files <span style="color: #0000ff;">where</span> type = 0  <span style="color: #0000ff;">group by</span> DB_NAME(database_id)),<br />
ldf as<br />
( <span style="color: #0000ff;">SELECT</span> DB_NAME(database_id) <span style="color: #0000ff;">AS</span> DatabaseName,  Max(Name) <span style="color: #0000ff;">AS</span> Logical_Name,<br />
<span style="color: #0000ff;">     Max</span>(Physical_Name) as Physical_name,<br />
<span style="color: #0000ff;">     sum</span>((size*8)/1024) SizeMB<br />
<span style="color: #0000ff;">     FROM</span> sys.master_files <span style="color: #0000ff;">where</span> type = 1  <span style="color: #0000ff;">group by</span> DB_NAME(database_id) )<br />
<span style="color: #0000ff;">SELECT</span><br />
   mdf.DatabaseName, mdf.SizeMB +ldf.SizeMB SizeMb,<br />
   convert(dec(5,0),100 * convert(dec(15,2),ldf.SizeMB)/mdf.SizeMB) as LogPercent,<br />
   recovery_model_desc,<br />
   case log_reuse_wait_desc when 'Nothing' then ''<br />
         else log_reuse_wait_desc end as   'LogReuseWait',<br />
   mdf.SizeMB as MdfSize , ldf.SizeMB as LogSize,<br />
   mdf.Logical_Name AS       MDFLogical_Name,    <br />
   Mdf.Physical_Name,   <br />
   ldf.Logical_Name AS LDFLogical_Name,<br />
   ldf.physical_name<br />
<span style="color: #0000ff;">FROM</span> mdf <span style="color: #0000ff;">inner join</span><br />
ldf on mdf.DatabaseName = ldf.DatabaseName  <span style="color: #0000ff;">inner join</span> sys.databases s on s.name = mdf.DatabaseName<br />
--where log_reuse_wait_desc &lt;&gt; 'nothing'<br />
<span style="color: #0000ff;">order by 2 desc</span></code></p>
]]></content:encoded>
			<wfw:commentRss>http://sqlinsight.net/blog/?feed=rss2&#038;p=264</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Find the users and their roles in a Database</title>
		<link>http://sqlinsight.net/blog/?p=254</link>
		<comments>http://sqlinsight.net/blog/?p=254#comments</comments>
		<pubDate>Mon, 02 Apr 2012 19:59:03 +0000</pubDate>
		<dc:creator>Steve Schneider</dc:creator>
				<category><![CDATA[SQL 2005]]></category>
		<category><![CDATA[SQL 2008]]></category>
		<category><![CDATA[SQL Administration]]></category>

		<guid isPermaLink="false">http://sqlinsight.net/blog/?p=254</guid>
		<description><![CDATA[Do you need to know all the users for a single database&#8230;and also to know what roles they have? Try this SQL: select m.Name, isnull(p.name,&#8221;) as Role From sys.database_principals m left join sys.database_role_members r on r.member_principal_id = m.principal_id left outer &#8230; <a href="http://sqlinsight.net/blog/?p=254">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>Do you need to know all the users for a single database&#8230;and also to know what roles they have? Try this SQL:</p>
<p style="padding-left: 30px;">
<span style="color: #0000ff;">select</span> m.Name, isnull(p.name,&#8221;) as Role<br />
<span style="color: #0000ff;">From</span> sys.database_principals m<span style="color: #0000ff;"> left join</span><br />
sys.database_role_members r on r.member_principal_id = m.principal_id <span style="color: #0000ff;">left outer join</span><br />
sys.database_principals p on p.principal_id = r.role_principal_id<br />
<span style="color: #0000ff;">where</span> m.type =&#8217;s&#8217;<br />
<span style="color: #0000ff;">order by</span> Role desc, m.name</p>
]]></content:encoded>
			<wfw:commentRss>http://sqlinsight.net/blog/?feed=rss2&#038;p=254</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>When were your statistics last updated?</title>
		<link>http://sqlinsight.net/blog/?p=250</link>
		<comments>http://sqlinsight.net/blog/?p=250#comments</comments>
		<pubDate>Fri, 30 Mar 2012 15:16:40 +0000</pubDate>
		<dc:creator>Steve Schneider</dc:creator>
				<category><![CDATA[Performance Tuning]]></category>
		<category><![CDATA[SQL 2005]]></category>
		<category><![CDATA[SQL 2008]]></category>

		<guid isPermaLink="false">http://sqlinsight.net/blog/?p=250</guid>
		<description><![CDATA[Introduced in sql 2005 the following query will tell you the date your statistics were last update for each of indexes of a table&#8230; USE AdventureWorks; GO SELECT name AS index_name, STATS_DATE(object_id, index_id) AS statistics_update_date FROM sys.indexes WHERE object_id = &#8230; <a href="http://sqlinsight.net/blog/?p=250">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>Introduced in sql 2005 the following query will tell you the date your statistics were last update for each of indexes of a table&#8230;<span id="more-250"></span></p>
<p>USE AdventureWorks;<br />
GO<br />
SELECT name AS index_name,<br />
STATS_DATE(object_id, index_id) AS statistics_update_date<br />
FROM sys.indexes<br />
WHERE object_id = OBJECT_ID(&#8216;Person.Address&#8217;);<br />
GO</p>
<p>Instead of &#8216;Person.Address&#8217; &#8230; use your own table name.</p>
<p>I found this at this site:  <a href="http://msdn.microsoft.com/en-us/library/ms190330(v=sql.90).aspx">http://msdn.microsoft.com/en-us/library/ms190330(v=sql.90).aspx</a></p>
<p>&nbsp;</p>
<p>&nbsp;</p>
]]></content:encoded>
			<wfw:commentRss>http://sqlinsight.net/blog/?feed=rss2&#038;p=250</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Improved EventLogs in Win 2008</title>
		<link>http://sqlinsight.net/blog/?p=243</link>
		<comments>http://sqlinsight.net/blog/?p=243#comments</comments>
		<pubDate>Thu, 29 Mar 2012 18:56:04 +0000</pubDate>
		<dc:creator>Steve Schneider</dc:creator>
				<category><![CDATA[SQL Administration]]></category>

		<guid isPermaLink="false">http://sqlinsight.net/blog/?p=243</guid>
		<description><![CDATA[Recently at one client location we had numerous unexplained cluster failovers. I had SQL Server and Analysis Services running on the clusters. When analysis was done on the failover, the analysts found that the &#8220;FlightRecorder&#8221; showed errors immediately before the &#8230; <a href="http://sqlinsight.net/blog/?p=243">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>Recently at one client location we had numerous unexplained cluster failovers. I had SQL Server and Analysis Services running on the clusters. When analysis was done on the failover, the analysts found that the &#8220;FlightRecorder&#8221; showed errors immediately before the failover. The Flight Recorder got the blame for the failover. When i was brought in, i took a closer look at the log and i noted serveral things: <span id="more-243"></span><br />
1. The core issue was that the Flight Recorder&#8217;s drive &#8216;disappeared&#8217; from the cluster before the Flight Recorder error.<br />
2. The SQL Server also complained about the lack of a drive&#8230;but it was slower to complain than Flight Recorder.<br />
3. Prior to the Flight Recorder error, the &#8220;Node Mgr&#8221; took one of the nodes out of the cluster.  WHy?  Because a drive disappeared.</p>
<p>When i first investigated this issue, i focused on the SQL error logs&#8230;because I have extensive experience with them&#8230;and they have generally served my purposes. This time, because the clusters are virtual i found better evidence in the Cluster event logs. In fact in the &#8220;Cluster Event&#8221; logs i also found all that i was used to finding in the SQL logs. In addition, i found the logs faster (by far) the SQL Logs. Also they are much easier to search thru, and you&#8217;ll find a wider filter capability. Lastly you can save your search criteria. These are all reasons to switch to the new, native Windows&#8217; event logs when on a new, modern box.</p>
<p>Learning point: If you&#8217;re on a modern cluster&#8230;seek out the &#8220;Cluster Event Logs&#8221; and do your research there. You&#8217;ll save time and have an easier experience doing so. (Modern, here, is defined as Windows 2008 or newer.)</p>
]]></content:encoded>
			<wfw:commentRss>http://sqlinsight.net/blog/?feed=rss2&#038;p=243</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Determine &#8220;Locked Paged&#8221; use across your domain&#8230;</title>
		<link>http://sqlinsight.net/blog/?p=244</link>
		<comments>http://sqlinsight.net/blog/?p=244#comments</comments>
		<pubDate>Tue, 28 Feb 2012 19:23:06 +0000</pubDate>
		<dc:creator>Steve Schneider</dc:creator>
				<category><![CDATA[SQL 2005]]></category>
		<category><![CDATA[SQL 2008]]></category>
		<category><![CDATA[SQL Administration]]></category>

		<guid isPermaLink="false">http://sqlinsight.net/blog/?p=244</guid>
		<description><![CDATA[So, building on my previous blog entry, now, let&#8217;s open a multi-server query and run this script that follows.  It will tell you for each server it&#8217;s version and how much memory is in locked pages. declare @version varchar(10) select &#8230; <a href="http://sqlinsight.net/blog/?p=244">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>So, building on my previous blog entry, now, let&#8217;s open a multi-server query and run this script that follows.  It will tell you for each server it&#8217;s version and how much memory is in locked pages.<span id="more-244"></span></p>
<p>declare @version varchar(10)</p>
<p>select @version = ltrim(substring (@@version, CHARINDEX(&#8216;.&#8217;,@@version)-2,2))</p>
<p>If @version = 10</p>
<p>select</p>
<p>convert(varchar(5), @version) as [Version],</p>
<p>convert (varchar(10),locked_page_allocations_kb)  as LockedMemory</p>
<p>from sys.dm_os_process_memory</p>
<p>else</p>
<p>select</p>
<p>convert(varchar(5), @version) as [Version],</p>
<p>convert (varchar(10),sum(awe_allocated_kb) ) as LockedMemory</p>
<p>from sys.dm_os_memory_clerks</p>
]]></content:encoded>
			<wfw:commentRss>http://sqlinsight.net/blog/?feed=rss2&#038;p=244</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Programmatically act on SQL Version</title>
		<link>http://sqlinsight.net/blog/?p=240</link>
		<comments>http://sqlinsight.net/blog/?p=240#comments</comments>
		<pubDate>Tue, 28 Feb 2012 16:42:15 +0000</pubDate>
		<dc:creator>Steve Schneider</dc:creator>
				<category><![CDATA[SQL 2000]]></category>
		<category><![CDATA[SQL 2005]]></category>
		<category><![CDATA[SQL 2008]]></category>
		<category><![CDATA[SQL Administration]]></category>

		<guid isPermaLink="false">http://sqlinsight.net/blog/?p=240</guid>
		<description><![CDATA[I often have scripts that run across multiple versions of SQL &#8230; more and more 2008&#8242;s and less and less 2000&#8242;s.  In doing so, i need to take different actions based on that version.  Here&#8217;s the simple technique that i &#8230; <a href="http://sqlinsight.net/blog/?p=240">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>I often have scripts that run across multiple versions of SQL &#8230; more and more 2008&#8242;s and less and less 2000&#8242;s.  In doing so, i need to take different actions based on that version.  Here&#8217;s the simple technique that i have developed &#8230; it currently depends on Microsoft continueing to use periods in their version naming scheme&#8230; i don&#8217;t think that that will change soon!</p>
<p><a href="mailto:select@version">select  </a><span style="color: #ff00ff; font-size: x-small;"><span style="color: #ff00ff; font-size: x-small;">ltrim</span></span><span style="color: #808080; font-size: x-small;"><span style="color: #808080; font-size: x-small;">(</span></span><span style="color: #ff00ff; font-size: x-small;"><span style="color: #ff00ff; font-size: x-small;">substring</span></span><span style="color: #808080; font-size: x-small;"><span style="color: #808080; font-size: x-small;">(</span></span><span style="color: #ff00ff; font-size: x-small;"><span style="color: #ff00ff; font-size: x-small;">@@version</span></span><span style="color: #808080; font-size: x-small;"><span style="color: #808080; font-size: x-small;">,</span></span><span style="color: #ff00ff; font-size: x-small;"><span style="color: #ff00ff; font-size: x-small;">CHARINDEX</span></span><span style="color: #808080; font-size: x-small;"><span style="color: #808080; font-size: x-small;">(</span></span><span style="color: #ff0000; font-size: x-small;"><span style="color: #ff0000; font-size: x-small;">&#8216;.&#8217;</span></span><span style="color: #808080; font-size: x-small;"><span style="color: #808080; font-size: x-small;">,</span></span><span style="color: #ff00ff; font-size: x-small;"><span style="color: #ff00ff; font-size: x-small;">@@version</span></span><span style="color: #808080; font-size: x-small;"><span style="color: #808080; font-size: x-small;">)-</span></span><span style="font-size: x-small;">2</span><span style="color: #808080; font-size: x-small;"><span style="color: #808080; font-size: x-small;">,</span></span><span style="font-size: x-small;">2</span><span style="color: #808080; font-size: x-small;"><span style="color: #808080; font-size: x-small;">))</span></span></p>
<p>Steve</p>
]]></content:encoded>
			<wfw:commentRss>http://sqlinsight.net/blog/?feed=rss2&#038;p=240</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>MSDB db too big?</title>
		<link>http://sqlinsight.net/blog/?p=236</link>
		<comments>http://sqlinsight.net/blog/?p=236#comments</comments>
		<pubDate>Tue, 10 Jan 2012 19:55:33 +0000</pubDate>
		<dc:creator>Steve Schneider</dc:creator>
				<category><![CDATA[Performance Tuning]]></category>
		<category><![CDATA[SQL 2005]]></category>
		<category><![CDATA[SQL 2008]]></category>
		<category><![CDATA[SQL Administration]]></category>

		<guid isPermaLink="false">http://sqlinsight.net/blog/?p=236</guid>
		<description><![CDATA[Microsoft provides &#8220;sp_delete_backuphistory &#8217;6/1/2011&#8242;&#8220;.   However, this can take a very long time unless you also add indexes to the backup table.  This is what did the trick for me: Create Nonclustered index idx_backupset_finishdate ON backupset (backup_finish_date) INCLUDE (backup_set_id, media_set_id) What &#8230; <a href="http://sqlinsight.net/blog/?p=236">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>Microsoft provides &#8220;<span style="color: #0000ff;">sp_delete_backuphistory</span> <span style="color: #ff0000;">&#8217;6/1/2011&#8242;</span>&#8220;.   However, this can take a very long time unless you also add indexes to the backup table.  This is what did the trick for me:</p>
<p><span style="color: #0000ff;">Create Nonclustered index</span> idx_backupset_finishdate <span style="color: #0000ff;">ON</span> backupset (backup_finish_date) <span style="color: #0000ff;">INCLUDE</span> (backup_set_id, media_set_id)</p>
<p>What was taking 20 minutes now takes 1 minute.</p>
<p>Enjoy!</p>
]]></content:encoded>
			<wfw:commentRss>http://sqlinsight.net/blog/?feed=rss2&#038;p=236</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Impersonation, Execute As &amp; Remote queries</title>
		<link>http://sqlinsight.net/blog/?p=231</link>
		<comments>http://sqlinsight.net/blog/?p=231#comments</comments>
		<pubDate>Fri, 30 Dec 2011 18:04:22 +0000</pubDate>
		<dc:creator>Steve Schneider</dc:creator>
				<category><![CDATA[SQL 2005]]></category>
		<category><![CDATA[SQL 2008]]></category>
		<category><![CDATA[SQL Administration]]></category>

		<guid isPermaLink="false">http://sqlinsight.net/blog/?p=231</guid>
		<description><![CDATA[This week i had a developer creating a process (job) where a database user was to have authority to query remote machines.  To debug the process the developer needed to assume the role of the user running in the application.  In &#8230; <a href="http://sqlinsight.net/blog/?p=231">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>This week i had a developer creating a process (job) where a database user was to have authority to query remote machines.  To debug the process the developer needed to assume the role of the user running in the application.  In the past i used the &#8220;<span style="color: #0000ff;">Execute As Login</span>&#8220;.  This had problems this time.<span id="more-231"></span></p>
<p>First, it is very useful in such situations to know what &#8220;user&#8221; is in &#8216;control&#8217;.  Thus, the &#8216;<span style="color: #0000ff;">select user_name()</span>&#8216; variations.  For information on the choice of &#8220;<span style="color: #0000ff;">Login or User</span>&#8221; see <a title="SQL Server: Execute As" href="http://msdn.microsoft.com/en-us/library/ms181362.aspx">execute as</a>.  Finally, don&#8217;t forget to &#8220;revert&#8221;!</p>
<p>In short, the solution is posted below:</p>
<p><span style="color: #339966;">/*</span><br />
<span style="color: #008000;"><span style="font-family: Courier New;"><span style="color: #339966;">GRANT IMPERSONATE ON USER:: User1 TO [ddd\user2];</span><br />
<span style="color: #339966;"> GO</span><br />
<span style="color: #339966;"> ALTER DATABASE  myDb SET TRUSTWORTHY ON</span><br />
<span style="color: #339966;"> </span><span style="color: #339966;">*/</span><br />
</span></span> &#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;<br />
<span style="color: #0000ff;">select SUSER_NAME(), USER_NAME(), ORIGINAL_LOGIN();</span><br />
<span style="color: #0000ff;"> use MyDB  ;</span><br />
<span style="color: #339966;">&#8211;execute as login = &#8216;MyDBuser&#8217;;</span><br />
<span style="color: #0000ff;">execute as user = &#8216;MyDBuser&#8217;;</span><br />
<span style="color: #0000ff;"> select SUSER_NAME(), USER_NAME(), ORIGINAL_LOGIN();</span><br />
<span style="color: #0000ff;"> select top 10 * From Server1.MyDB.dbo .repl_to_test ;</span><br />
<span style="color: #0000ff;"> revert;</span><br />
<span style="color: #0000ff;"> selectSUSER_NAME(), USER_NAME();</span></p>
]]></content:encoded>
			<wfw:commentRss>http://sqlinsight.net/blog/?feed=rss2&#038;p=231</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>DB mail Query parameter not working</title>
		<link>http://sqlinsight.net/blog/?p=226</link>
		<comments>http://sqlinsight.net/blog/?p=226#comments</comments>
		<pubDate>Fri, 23 Dec 2011 21:47:44 +0000</pubDate>
		<dc:creator>Steve Schneider</dc:creator>
				<category><![CDATA[SQL 2005]]></category>
		<category><![CDATA[SQL 2008]]></category>

		<guid isPermaLink="false">http://sqlinsight.net/blog/?p=226</guid>
		<description><![CDATA[On one of my servers the query parameter just wasn&#8217;t working.  I kept getting this error: Msg 22050, Level 16, State 1, Line 0 Error formatting query, probably invalid parameters Msg 14661, Level 16, State 1, Procedure sp_send_dbmail, Line 504 &#8230; <a href="http://sqlinsight.net/blog/?p=226">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>On one of my servers the query parameter just wasn&#8217;t working.  I kept getting this error:</p>
<h6><span style="color: #ff0000; font-family: Calibri;">Msg 22050, Level 16, State 1, Line 0<br />
Error formatting query, probably invalid parameters<br />
Msg 14661, Level 16, State 1, Procedure sp_send_dbmail, Line 504<br />
Query execution failed: Msg 208, Level 16, State 1, Server UFOsqlAB, Line 1<br />
Invalid object name &#8216;CountySalesTax&#8217;.</span></h6>
<p>What to do? <span id="more-226"></span> The solution?  Simple actually.  Include the &#8220;use database;&#8221; before the query as in:</p>
<p><span style="color: #0000ff;">Exec msdb.dbo.sp_send_dbmail<br />
@recipients=&#8217;Steves@sqlinsight&#8217;,<br />
@Query = &#8216;Use MyDb; select * from mytable&#8217;,<br />
@body = &#8216;Job complete&#8217;;</span></p>
]]></content:encoded>
			<wfw:commentRss>http://sqlinsight.net/blog/?feed=rss2&#038;p=226</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>SQL Server&#8217;s Auto Growth settings</title>
		<link>http://sqlinsight.net/blog/?p=219</link>
		<comments>http://sqlinsight.net/blog/?p=219#comments</comments>
		<pubDate>Tue, 20 Dec 2011 22:40:00 +0000</pubDate>
		<dc:creator>Steve Schneider</dc:creator>
				<category><![CDATA[SQL 2005]]></category>
		<category><![CDATA[SQL 2008]]></category>
		<category><![CDATA[SQL Administration]]></category>

		<guid isPermaLink="false">http://sqlinsight.net/blog/?p=219</guid>
		<description><![CDATA[Over the last week I&#8217;ve been finding an unusual number of log file growths.  I did some investigation and found a good script to help me track what was the current status for file growths.  It is as follows: SELECT &#8230; <a href="http://sqlinsight.net/blog/?p=219">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>Over the last week I&#8217;ve been finding an unusual number of log file growths.  I did some investigation and found a good script to help me track what was the current status for file growths.  It is as follows:<span id="more-219"></span></p>
<p><span style="color: #0000ff;">SELECT</span><br />
<span style="color: #0000ff;"> SD.database_id,</span><br />
<span style="color: #0000ff;"> SD.name,</span><br />
<span style="color: #0000ff;"> SF.name as FileName,</span><br />
<span style="color: #0000ff;"> recovery_model_desc,</span><br />
<span style="color: #0000ff;"> CASE SF.status &amp; 0&#215;100000 WHEN 1048576 THEN &#8216;Percentage&#8217; WHEN 0 THEN &#8216;MB&#8217; END AS &#8216;GROWTH Option&#8217;,</span><br />
<span style="color: #0000ff;"> size * 8/1000 as DBsizeMb ,</span><br />
<span style="color: #0000ff;"> CASE SF.status &amp; 0&#215;100000 when 1048576 then sf.growth else sf.growth * 8/1000 end as growth</span><br />
<span style="color: #0000ff;"> FROM SYS.SYSALTFILES SF inner JOIN</span><br />
<span style="color: #0000ff;"> SYS.DATABASES SD</span><br />
<span style="color: #0000ff;"> ON SD.database_id = SF.dbid</span><br />
<span style="color: #0000ff;"> where sd.database_id &gt; 5</span><br />
<span style="color: #0000ff;"> order by sd.name ,size desc</span></p>
]]></content:encoded>
			<wfw:commentRss>http://sqlinsight.net/blog/?feed=rss2&#038;p=219</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

