<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" media="screen" href="/~d/styles/rss2full.xsl"?><?xml-stylesheet type="text/css" media="screen" href="http://feeds.feedburner.com/~d/styles/itemcontent.css"?><rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:sy="http://purl.org/rss/1.0/modules/syndication/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:creativeCommons="http://backend.userland.com/creativeCommonsRssModule" xmlns:feedburner="http://rssnamespace.org/feedburner/ext/1.0" version="2.0">

<channel>
	<title>SQLServerPedia</title>
	
	<link>http://sqlserverpedia.com/blog</link>
	<description />
	<lastBuildDate>Thu, 29 Jul 2010 19:52:36 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="self" type="application/rss+xml" href="http://feeds.feedburner.com/sqlserverpedia" /><feedburner:info uri="sqlserverpedia" /><atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="hub" href="http://pubsubhubbub.appspot.com/" /><creativeCommons:license>http://creativecommons.org/licenses/by-nc-nd/3.0/</creativeCommons:license><feedburner:emailServiceId>sqlserverpedia</feedburner:emailServiceId><feedburner:feedburnerHostname>http://feedburner.google.com</feedburner:feedburnerHostname><item>
		<title>Tricks with User Settable Perfmon Counters</title>
		<link>http://feedproxy.google.com/~r/sqlserverpedia/~3/ugoONSralxQ/</link>
		<comments>http://sqlserverpedia.com/blog/sql-server-bloggers/tricks-with-user-settable-perfmon-counters/#comments</comments>
		<pubDate>Thu, 29 Jul 2010 19:52:36 +0000</pubDate>
		<dc:creator>Michael Swart</dc:creator>
				<category><![CDATA[SQL Server Bloggers]]></category>

		<guid isPermaLink="false">http://michaeljswart.com/?p=800</guid>
		<description><![CDATA[So there's this underrated SQL Server feature called User Settable Counters and they help SQL Server developers create our own custom perfmon counters.]]></description>
			<content:encoded><![CDATA[<p>So there&#8217;s this underrated SQL Server feature called <a title="Microsoft Tecnhet docs" href="http://technet.microsoft.com/en-us/library/ms187480.aspx">User Settable</a> Counters and they help SQL Server developers create our own custom perfmon counters.</p>
<p>You use them by using syntax like the following:</p>

<pre class="brush:tsql">EXEC sp_user_counter1 @newvalue</pre>

<p>This updates a counter than can be tracked using windows performance monitor etc&#8230;</p>
<h3>Trick 1</h3>
<p>Unfortunately this is not a counter that can be incremented. You have to know the new value to set. It would be great if we had stored procedures  like sp_increment_counterX so that we could simply increment the existing value of the counter by any given value. Well ask and you shall receive!</p>

<pre class="brush:tsql">USE master
GO
�
CREATE PROCEDURE sp_increment_counter1
	@VALUE INT
AS
�
	DECLARE @newValue INT
	SELECT @newValue = @VALUE + cntr_value
	FROM sys.dm_os_performance_counters
	WHERE instance_name = 'User counter 1'
	and [OBJECT_NAME] like '%User Settable%'
	and counter_name = 'Query'
�
	EXEC sp_user_counter1 @newValue
GO</pre>

<p>I like this stored procedure because it&#8217;s very light weight:</p>
<ul>
<li>The cpu/IO/memory is negligible.</li>
<li>It doesn&#8217;t take or hold any significant locks.</li>
</ul>
<h3>Trick 2</h3>
<p>If you have a lot of spare time, you can the commands sp_user_counter combined with WAITFOR to make some pretty pictures of your favorite skyline!</p>
<div id="attachment_801" class="wp-caption alignnone" style="width: 791px"><img class="size-full wp-image-801 " title="(yeah, that's supposed to be the CN Tower)" src="http://michaeljswart.com/wp-content/uploads/2010/07/perfmon.png" alt="Toronto Skyline" width="781" height="525" /><p class="wp-caption-text">Like the Toronto Skyline</p></div>
<p>Based on this this photo from <a title="Toronto at Flickr" href="http://www.flickr.com/photos/bribri/810993401/">BriYYZ (at Flickr)</a>:</p>
<div id="attachment_802" class="wp-caption alignnone" style="width: 310px"><a href="http://www.flickr.com/photos/bribri/810993401/"><img class="size-medium wp-image-802 " title="Toronto skyline" src="http://michaeljswart.com/wp-content/uploads/2010/07/toronto-300x157.png" alt="Toronto skyline" width="300" height="157" /></a><p class="wp-caption-text">Toronto skyline</p></div>
<img src="http://feeds.feedburner.com/~r/MichaelSwart/~4/VikQrcJo_Dk" height="1" width="1"/><div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/sqlserverpedia?a=ugoONSralxQ:VikQrcJo_Dk:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/sqlserverpedia?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/sqlserverpedia?a=ugoONSralxQ:VikQrcJo_Dk:G79ilh31hkQ"><img src="http://feeds.feedburner.com/~ff/sqlserverpedia?d=G79ilh31hkQ" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/sqlserverpedia?a=ugoONSralxQ:VikQrcJo_Dk:YwkR-u9nhCs"><img src="http://feeds.feedburner.com/~ff/sqlserverpedia?d=YwkR-u9nhCs" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/sqlserverpedia/~4/ugoONSralxQ" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://sqlserverpedia.com/blog/sql-server-bloggers/tricks-with-user-settable-perfmon-counters/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://sqlserverpedia.com/blog/sql-server-bloggers/tricks-with-user-settable-perfmon-counters/</feedburner:origLink></item>
		<item>
		<title>Finding Key Lookups In Cached Execution Plans</title>
		<link>http://feedproxy.google.com/~r/sqlserverpedia/~3/fz9upIRoSCM/</link>
		<comments>http://sqlserverpedia.com/blog/sql-server-bloggers/finding-key-lookups-in-cached-execution-plans/#comments</comments>
		<pubDate>Thu, 29 Jul 2010 19:15:01 +0000</pubDate>
		<dc:creator>Kendal Van Dyke</dc:creator>
				<category><![CDATA[SQL Server Bloggers]]></category>

		<guid isPermaLink="false">tag:blogger.com,1999:blog-2173119910600284569.post-8338379524176994975</guid>
		<description><![CDATA[Ask anyone with performance tuning experience to list the most expensive operations in an execution plan and it's a safe bet you'll find key lookups near the top. The good news is they're usually easy to fix - Glenn Berry (Blog &#124; Twitter) blogged about...]]></description>
			<content:encoded><![CDATA[<p>Ask anyone with performance tuning experience to list the most expensive operations in an execution plan and it's a safe bet you'll find <a href="http://msdn.microsoft.com/en-us/library/bb326635.aspx" >key lookups</a> near the top. The good news is they're usually easy to fix - Glenn Berry (<a href="http://glennberrysqlperformance.spaces.live.com/blog/" >Blog</a> | <a href="http://twitter.com/glennalanberry" >Twitter</a>) <a href="http://glennberrysqlperformance.spaces.live.com/blog/cns!45041418ECCAA960!6962.entry" >blogged about it recently</a> and many others have written about the subject as well. For most people though, it's finding out when and where they're happening that's the tough part.</p>  <p><strong>Background</strong>     <br />A key lookup occurs when a nonclustered index is used to satisfy a query but doesn't include all the columns the query is asking for so they have to be retrieved from the corresponding clustered index (or heap if there's no clustered index) that the nonclustered index is based on. It's expensive because it requires fetching additional pages into the buffer which has a double whammy effect: if the pages aren't already in the buffer you have to wait for the disk subsystem to retrieve them and you're filling up the buffer with up to twice the number of data pages you'd need if you could just stick with using the nonclustered index to begin with.</p>  <p><strong>Finding Key Lookups - There's a DMV For That      <br /></strong>SQL Server keeps track of how many key lookups occur against every index in <a href="http://msdn.microsoft.com/en-us/library/ms188755.aspx" >sys.dm_db_index_usage_stats</a> (in the user_lookups column). Interesting, but to be useful we need to know what queries are causing the lookups. Enter the DMV <a href="http://msdn.microsoft.com/en-us/library/ms189741.aspx" >sys.dm_exec_query_stats</a> which keeps track of a wealth of information about how many times a query has been executed and the resources (CPU, disk, etc.) its used. Plug the sql_handle and plan_handle columns into the DMFs <a href="http://msdn.microsoft.com/en-us/library/ms181929.aspx" >sys.dm_exec_sql_text</a> and <a href="http://msdn.microsoft.com/en-us/library/ms189747.aspx" >sys.dm_exec_query_plan</a>, respectively, and we get the text and execution plan for the query. Because the execution plan is an XML document we can leverage SQL Server's native XML capabilities to find any key lookup operations that are occurring. Join them all together and - voila! - we can see every cached query that's got a key lookup, the additional columns being retrieved, and the execution plan, ordered by worst offender first - everything we need to know to work on eliminating the key lookups that are draining performance. Happy tuning!</p>  <p>NOTE: As the comments in the header suggest , exercise caution when running this against a production server…executing sys.dm_exec_query_plan can be resource intensive when your server contains a lot of cached plans. You have been warned!</p> <pre style="font-size: 12px" class="brush:tsql">     
/*********************************************************************************************      
Find Key Lookups in Cached Plans v1.00 (2010-07-27)       
(C) 2010, Kendal Van Dyke       
      
Feedback: mailto:kendal.vandyke@gmail.com       
      
License:       
&#160;&#160; This query is free to download and use for personal, educational, and internal       
&#160;&#160; corporate purposes, provided that this header is preserved. Redistribution or sale       
&#160;&#160; of this query, in whole or in part, is prohibited without the author's express       
&#160;&#160; written consent.       
&#160;&#160; 
Note:       
&#160;&#160; Exercise caution when running this in production!       
      
&#160;&#160; The function sys.dm_exec_query_plan() is resource intensive and can put strain       
&#160;&#160; on a server when used to retrieve all cached query plans.       
      
&#160;&#160; Consider using TOP in the initial select statement (insert into @plans)       
&#160;&#160; to limit the impact of running this query or run during non-peak hours       
*********************************************************************************************/       
DECLARE @plans TABLE      
&#160;&#160;&#160; (      
&#160;&#160;&#160;&#160;&#160; query_text NVARCHAR(MAX) ,      
&#160;&#160;&#160;&#160;&#160; o_name SYSNAME ,      
&#160;&#160;&#160;&#160;&#160; execution_plan XML ,      
&#160;&#160;&#160;&#160;&#160; last_execution_time DATETIME ,      
&#160;&#160;&#160;&#160;&#160; execution_count BIGINT ,      
&#160;&#160;&#160;&#160;&#160; total_worker_time BIGINT ,      
&#160;&#160;&#160;&#160;&#160; total_physical_reads BIGINT ,      
&#160;&#160;&#160;&#160;&#160; total_logical_reads BIGINT      
&#160;&#160;&#160; ) ;      
      
DECLARE @lookups TABLE      
&#160;&#160;&#160; (      
&#160;&#160;&#160;&#160;&#160; table_name SYSNAME ,      
&#160;&#160;&#160;&#160;&#160; index_name SYSNAME ,      
&#160;&#160;&#160;&#160;&#160; index_cols NVARCHAR(MAX)      
&#160;&#160;&#160; ) ;       
      
WITH&#160;&#160;&#160; query_stats      
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; AS ( SELECT&#160;&#160; [sql_handle] ,      
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; [plan_handle] ,      
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; MAX(last_execution_time) AS last_execution_time ,      
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; SUM(execution_count) AS execution_count ,      
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; SUM(total_worker_time) AS total_worker_time ,      
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; SUM(total_physical_reads) AS total_physical_reads ,      
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; SUM(total_logical_reads) AS total_logical_reads      
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; FROM&#160;&#160;&#160;&#160; sys.dm_exec_query_stats      
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; GROUP BY [sql_handle] ,      
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; [plan_handle]      
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; )      
&#160;&#160;&#160; INSERT&#160; INTO @plans      
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; ( query_text ,      
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; o_name ,      
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; execution_plan ,      
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; last_execution_time ,      
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; execution_count ,      
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; total_worker_time ,      
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; total_physical_reads ,      
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; total_logical_reads      
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; )      
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; SELECT /*TOP 50*/      
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; sql_text.[text] ,      
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; CASE WHEN sql_text.objectid IS NOT NULL      
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; THEN ISNULL(OBJECT_NAME(sql_text.objectid,      
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; sql_text.[dbid]),      
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; 'Unresolved')      
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; ELSE CAST('Ad-hoc\Prepared' AS SYSNAME)      
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; END ,      
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; query_plan.query_plan ,      
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; query_stats.last_execution_time ,      
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; query_stats.execution_count ,      
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; query_stats.total_worker_time ,      
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; query_stats.total_physical_reads ,      
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; query_stats.total_logical_reads      
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; FROM&#160;&#160;&#160; query_stats      
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; CROSS APPLY sys.dm_exec_sql_text(query_stats.sql_handle)      
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; AS [sql_text]      
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; CROSS APPLY sys.dm_exec_query_plan(query_stats.plan_handle)      
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; AS [query_plan]      
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; WHERE&#160;&#160; query_plan.query_plan IS NOT NULL ;      
      
      
;WITH XMLNAMESPACES (      
&#160;&#160; DEFAULT 'http://schemas.microsoft.com/sqlserver/2004/07/showplan'      
),      
lookups AS (      
&#160;&#160; SELECT&#160; DB_ID(REPLACE(REPLACE(keylookups.keylookup.value('(Object/@Database)[1]',      
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; 'sysname'), '[', ''),      
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; ']', '')) AS [database_id] ,      
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; OBJECT_ID(keylookups.keylookup.value('(Object/@Database)[1]',      
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; 'sysname') + '.'      
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; + keylookups.keylookup.value('(Object/@Schema)[1]',      
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; 'sysname') + '.'      
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; + keylookups.keylookup.value('(Object/@Table)[1]', 'sysname')) AS [object_id] ,      
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; keylookups.keylookup.value('(Object/@Database)[1]', 'sysname') AS [database] ,      
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; keylookups.keyloookup.value('(Object/@Schema)[1]', 'sysname') AS [schema] ,      
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; keylookups.keylookup.value('(Object/@Table)[1]', 'sysname') AS [table] ,      
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; keylookups.keylookup.value('(Object/@Index)[1]', 'sysname') AS [index] ,      
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; REPLACE(keylookups.keylookup.query('      
for $column in DefinedValues/DefinedValue/ColumnReference       
return string($column/@Column)       
').value('.', 'varchar(max)'), ' ', ', ') AS [columns] ,      
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; plans.query_text ,      
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; plans.o_name,      
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; plans.execution_plan ,      
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; plans.last_execution_time ,      
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; plans.execution_count ,      
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; plans.total_worker_time ,      
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; plans.total_physical_reads,      
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; plans.total_logical_reads      
&#160;&#160; FROM&#160;&#160;&#160; @plans AS [plans]      
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; CROSS APPLY execution_plan.nodes('//RelOp/IndexScan[@Lookup=&quot;1&quot;]') AS keylookups ( keylookup )      
)       
SELECT&#160; lookups.[database] ,      
&#160;&#160;&#160;&#160;&#160;&#160;&#160; lookups.[schema] ,      
&#160;&#160;&#160;&#160;&#160;&#160;&#160; lookups.[table] ,      
&#160;&#160;&#160;&#160;&#160;&#160;&#160; lookups.[index] ,      
&#160;&#160;&#160;&#160;&#160;&#160;&#160; lookups.[columns] ,      
&#160;&#160;&#160;&#160;&#160;&#160;&#160; index_stats.user_lookups ,      
&#160;&#160;&#160;&#160;&#160;&#160;&#160; index_stats.last_user_lookup ,      
&#160;&#160;&#160;&#160;&#160;&#160;&#160; lookups.execution_count ,      
&#160;&#160;&#160;&#160;&#160;&#160;&#160; lookups.total_worker_time ,      
&#160;&#160;&#160;&#160;&#160;&#160;&#160; lookups.total_physical_reads ,      
&#160;&#160;&#160;&#160;&#160;&#160;&#160; lookups.total_logical_reads,      
&#160;&#160;&#160;&#160;&#160;&#160;&#160; lookups.last_execution_time ,      
&#160;&#160;&#160;&#160;&#160;&#160; lookups.o_name AS [object_name],      
&#160;&#160;&#160;&#160;&#160;&#160;&#160; lookups.query_text ,      
&#160;&#160;&#160;&#160;&#160;&#160;&#160; lookups.execution_plan      
FROM&#160;&#160;&#160; lookups      
&#160;&#160;&#160;&#160;&#160;&#160;&#160; INNER JOIN sys.dm_db_index_usage_stats AS [index_stats] ON lookups.database_id = index_stats.database_id      
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; AND lookups.[object_id] = index_stats.[object_id]      
WHERE&#160;&#160; index_stats.user_lookups &gt; 0      
&#160;&#160;&#160;&#160;&#160;&#160;&#160; AND lookups.[database] NOT IN ('[master]','[model]','[msdb]','[tempdb]')      
ORDER BY lookups.execution_count DESC      
--ORDER BY index_stats.user_lookups DESC      
--ORDER BY lookups.total_logical_reads DESC       
</pre>  <div class="blogger-post-footer"><img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2173119910600284569-8338379524176994975?l=kendalvandyke.blogspot.com' alt='' /></div><img src="http://feeds.feedburner.com/~r/blogspot/psal/~4/n4_nlqdETd4" height="1" width="1"/><div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/sqlserverpedia?a=fz9upIRoSCM:gQuo6inRLhU:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/sqlserverpedia?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/sqlserverpedia?a=fz9upIRoSCM:gQuo6inRLhU:G79ilh31hkQ"><img src="http://feeds.feedburner.com/~ff/sqlserverpedia?d=G79ilh31hkQ" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/sqlserverpedia?a=fz9upIRoSCM:gQuo6inRLhU:YwkR-u9nhCs"><img src="http://feeds.feedburner.com/~ff/sqlserverpedia?d=YwkR-u9nhCs" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/sqlserverpedia/~4/fz9upIRoSCM" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://sqlserverpedia.com/blog/sql-server-bloggers/finding-key-lookups-in-cached-execution-plans/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://sqlserverpedia.com/blog/sql-server-bloggers/finding-key-lookups-in-cached-execution-plans/</feedburner:origLink></item>
		<item>
		<title>Return of the 24 Hours of PASS</title>
		<link>http://feedproxy.google.com/~r/sqlserverpedia/~3/IKyP1_xWQsM/</link>
		<comments>http://sqlserverpedia.com/blog/professional-development/return-of-the-24-hours-of-pass/#comments</comments>
		<pubDate>Thu, 29 Jul 2010 14:09:32 +0000</pubDate>
		<dc:creator>Thomas LaRock</dc:creator>
				<category><![CDATA[Professional Development]]></category>
		<category><![CDATA[SQL Server Bloggers]]></category>

		<guid isPermaLink="false">http://thomaslarock.com/?p=4530</guid>
		<description><![CDATA[In case you missed it I wanted to let everyone know that we are planning on doing our third 24 Hours of PASS. I sent out a call for abstracts recently to the people that have been selected to present at the PASS Summit in November (about 70 people in total). I got back about [...]]]></description>
			<content:encoded><![CDATA[<p>In case you missed it I wanted to let everyone know that we are planning on doing our third 24 Hours of PASS. I sent out a call for abstracts recently to the people that have been selected to present at the PASS Summit in November (about 70 people in total). I got back about 40 responses to my initial email and 35 expressed interest in participating. I know, I know, 35 <em>is</em> a lot more than 24. After I figure out the schedule and assign slots then we&#8217;ll have more than enough people available to serve as a backup in case someone needs to back out at the last possible minute (hey, it happens!)</p>
<p>I targeted the PASS speaker list because we are looking to promote the PASS Summit and thought it was best to ask people if they were interested in promoting their sessions. This can be a great way to drive attendance for those speakers that are doing a pre/post con session. For others it can be a way for then to practice their session one more time before the Summit, or just some general shameless self-promotion.</p>
<p>The biggest change to our format this time is that we are going to spread the event over two days (September 15th and 16th). We are keeping the same start time(s) as the last event, promptly at 12 noon GMT for both days. We&#8217;ll run twelve straight sessions, then take a twelve hour respite, and then crank it back up again the next day. Hopefully that will allow for more people to attend all the sessions they want to see.</p>
<p>Yeah, I know&#8230;people on the other side of the Earth have a less than optimal viewing time. When we looked at the numbers for the last event we found that an overwhelming majority of the attendees are from the USA and Europe. So we decided to switch up the format a bit in order to make it easier for those attendees to attend more sessions this time around. If you were one of the few from the Asia/Pacific region and are miffed that you will be forced to spend your overnight hours watching the sessions live, feel free to send me an email and we can discuss everything in more detail.</p>
<p>You should be able to begin registering for the event on or around August 11th. Don&#8217;t hesitate to ask any questions about the event, I will do my best to answer them.</p>
<div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/sqlserverpedia?a=IKyP1_xWQsM:VF-MGnbNols:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/sqlserverpedia?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/sqlserverpedia?a=IKyP1_xWQsM:VF-MGnbNols:G79ilh31hkQ"><img src="http://feeds.feedburner.com/~ff/sqlserverpedia?d=G79ilh31hkQ" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/sqlserverpedia?a=IKyP1_xWQsM:VF-MGnbNols:YwkR-u9nhCs"><img src="http://feeds.feedburner.com/~ff/sqlserverpedia?d=YwkR-u9nhCs" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/sqlserverpedia/~4/IKyP1_xWQsM" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://sqlserverpedia.com/blog/professional-development/return-of-the-24-hours-of-pass/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://sqlserverpedia.com/blog/professional-development/return-of-the-24-hours-of-pass/</feedburner:origLink></item>
		<item>
		<title>Video: Disk Tuning and Optimization for SQL Server</title>
		<link>http://feedproxy.google.com/~r/sqlserverpedia/~3/wXd1Lq2Bs8w/</link>
		<comments>http://sqlserverpedia.com/blog/sql-server-2005/video-disk-tuning-and-optimization-for-sql-server/#comments</comments>
		<pubDate>Thu, 29 Jul 2010 14:00:00 +0000</pubDate>
		<dc:creator>Kevin Kline</dc:creator>
				<category><![CDATA[SQL Server 2005]]></category>
		<category><![CDATA[SQL Server Bloggers]]></category>

		<guid isPermaLink="false">http://kevinekline.com/?p=691</guid>
		<description><![CDATA[This video focuses on accelerated Disk Optimization and improved productivity with SQL Query Tuning.]]></description>
			<content:encoded><![CDATA[<p><object width="480" height="385"><param name="movie" value="http://www.youtube.com/v/3AzXktJtjko&amp;hl=en_US&amp;fs=1"></param><param name="allowFullScreen" value="true"></param><param name="allowscriptaccess" value="always"></param><embed src="http://www.youtube.com/v/3AzXktJtjko&amp;hl=en_US&amp;fs=1" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="480" height="385"></embed></object></p>
<p>This video focuses on accelerated Disk Optimization and improved productivity with SQL Query Tuning.</p>
<p>Video created Dec. 18, 2006.</p>
<input id="gwProxy" type="hidden" />
<p><!--Session data--></p>
<input id="jsProxy" onclick="if(typeof(jsCall)=='function'){jsCall();}else{setTimeout('jsCall()',500);}" type="hidden" />
<input id="gwProxy" type="hidden" />
<input id="jsProxy" onclick="if(typeof(jsCall)=='function'){jsCall();}else{setTimeout('jsCall()',500);}" type="hidden" />
<div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/sqlserverpedia?a=wXd1Lq2Bs8w:OcH0mH8Gh5E:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/sqlserverpedia?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/sqlserverpedia?a=wXd1Lq2Bs8w:OcH0mH8Gh5E:G79ilh31hkQ"><img src="http://feeds.feedburner.com/~ff/sqlserverpedia?d=G79ilh31hkQ" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/sqlserverpedia?a=wXd1Lq2Bs8w:OcH0mH8Gh5E:YwkR-u9nhCs"><img src="http://feeds.feedburner.com/~ff/sqlserverpedia?d=YwkR-u9nhCs" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/sqlserverpedia/~4/wXd1Lq2Bs8w" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://sqlserverpedia.com/blog/sql-server-2005/video-disk-tuning-and-optimization-for-sql-server/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://sqlserverpedia.com/blog/sql-server-2005/video-disk-tuning-and-optimization-for-sql-server/</feedburner:origLink></item>
		<item>
		<title>Database Backup Disk Space Capacity Planning</title>
		<link>http://feedproxy.google.com/~r/sqlserverpedia/~3/ibFtRNhdhoI/</link>
		<comments>http://sqlserverpedia.com/blog/sql-server-bloggers/database-backup-disk-space-capacity-planning/#comments</comments>
		<pubDate>Thu, 29 Jul 2010 12:50:51 +0000</pubDate>
		<dc:creator>Jeremy Carter</dc:creator>
				<category><![CDATA[SQL Server Bloggers]]></category>

		<guid isPermaLink="false">http://jeremycarterblog.com/?p=416</guid>
		<description><![CDATA[Database Backup Disk Space Capacity Planning. Try saying that three times fast! Thomas LaRock (aka SQLRockstar) just posted an excellent piece on capacity planning. As I was reading this I was thinking about how true it is that for so many people we just do not spend adequate time planning and there are not alot [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.flickr.com/photos/leehaywood/4204282006/"><img class="alignright size-medium wp-image-427" title="database-backup-disk-space-capacity-planning-3" src="http://jeremycarterblog.com/wp-content/uploads/2010/07/database-backup-disk-space-capacity-planning-3-300x118.png" alt="" width="300" height="118" /></a>Database Backup Disk Space Capacity Planning. Try saying that three times fast!</p>
<p><a href="http://thomaslarock.com/" >Thomas LaRock (aka SQLRockstar)</a> just posted an excellent piece on <a href="http://thomaslarock.com/2010/07/sql-university-capacity-planning-week/" >capacity planning</a>. As I was reading this I was thinking about how true it is that for so many people we just do not spend adequate time planning and there are not alot of resources out there to refer to.  At the same time I had just recently worked with a client planning their recovery strategy when the topic of disk space for the backups came up. Basically we needed to figure out how much disk space they would need for their objectives so that the proper sized san luns could be carved out. I had previously written this script to fullfill that need and thought I would share with everyone. I find it very handy for looking for trends in backup sizes as well as planning disk space/retention requirements.</p>
<p>The script is pulling alot of information from the backup history tables in msdb and then formatting it into a nice report. It will display how much the full, diff, and log backups are taking on a daily basis for each database along with totals. I&#8217;ve included a small sample of a result set below (with the db name changed to protect the innocent). In the example you can see the results for the summary of All Databases along with one of the databases.</p>
<pre class="brush:tsql">
SELECT
	[Database Name], [Start Date], [All Types],
	ISNULL([Full],'') AS [Full],
	ISNULL([Differential],'') AS [Differential],
	ISNULL([Transaction Log],'') AS [Transaction Log]
FROM(
	SELECT
		ISNULL(bu.database_name,'*All Databases')AS [Database Name],
		CASE bu.type
			WHEN 'D' THEN 'Full'
			WHEN 'I' THEN 'Differential'
			WHEN 'L' THEN 'Transaction Log'
			ELSE 'All Types'
		END as [Backup Type],
		ISNULL(convert(char(10), backup_start_date, 120),'All Dates' )as [Start Date],
		CAST((SUM(bu.backup_size/1024/1024)) AS int) AS [Size in MB]
	FROM msdb.dbo.backupset as bu
	WHERE DATEDIFF(d, backup_start_date, GETDATE()) &lt;= 6
	GROUP BY bu.database_name, convert(char(10), backup_start_date, 120),  bu.type
	WITH CUBE
) AS SourceTable
PIVOT(SUM([Size in MB]) FOR [Backup Type] IN ([All Types], [Full], [Differential], [Transaction Log])) AS PivotTable
ORDER BY [Database Name] ASC, convert(char(10), [Start Date], 120) DESC
</pre>
<p><a href="http://jeremycarterblog.com/wp-content/uploads/2010/07/database-backup-disk-space-capacity-planning.png"><img class="alignnone size-medium wp-image-419" title="database-backup-disk-space-capacity-planning" src="http://jeremycarterblog.com/wp-content/uploads/2010/07/database-backup-disk-space-capacity-planning-300x183.png" alt="" width="300" height="183" /></a></p>
<img src="http://jeremycarterblog.com/?ak_action=api_record_view&id=416&type=feed" alt="" /><div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/JeremyCarter?a=pd2HU5cBMT8:_GZhcCk52D8:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/JeremyCarter?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/JeremyCarter?a=pd2HU5cBMT8:_GZhcCk52D8:D7DqB2pKExk"><img src="http://feeds.feedburner.com/~ff/JeremyCarter?i=pd2HU5cBMT8:_GZhcCk52D8:D7DqB2pKExk" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/JeremyCarter?a=pd2HU5cBMT8:_GZhcCk52D8:nQ_hWtDbxek"><img src="http://feeds.feedburner.com/~ff/JeremyCarter?d=nQ_hWtDbxek" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/JeremyCarter?a=pd2HU5cBMT8:_GZhcCk52D8:bcOpcFrp8Mo"><img src="http://feeds.feedburner.com/~ff/JeremyCarter?d=bcOpcFrp8Mo" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/JeremyCarter?a=pd2HU5cBMT8:_GZhcCk52D8:3QFJfmc7Om4"><img src="http://feeds.feedburner.com/~ff/JeremyCarter?i=pd2HU5cBMT8:_GZhcCk52D8:3QFJfmc7Om4" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/JeremyCarter/~4/pd2HU5cBMT8" height="1" width="1"/><div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/sqlserverpedia?a=ibFtRNhdhoI:_GZhcCk52D8:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/sqlserverpedia?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/sqlserverpedia?a=ibFtRNhdhoI:_GZhcCk52D8:G79ilh31hkQ"><img src="http://feeds.feedburner.com/~ff/sqlserverpedia?d=G79ilh31hkQ" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/sqlserverpedia?a=ibFtRNhdhoI:_GZhcCk52D8:YwkR-u9nhCs"><img src="http://feeds.feedburner.com/~ff/sqlserverpedia?d=YwkR-u9nhCs" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/sqlserverpedia/~4/ibFtRNhdhoI" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://sqlserverpedia.com/blog/sql-server-bloggers/database-backup-disk-space-capacity-planning/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://sqlserverpedia.com/blog/sql-server-bloggers/database-backup-disk-space-capacity-planning/</feedburner:origLink></item>
		<item>
		<title>SQLServerPedia Status Update – 29th July 2010</title>
		<link>http://feedproxy.google.com/~r/sqlserverpedia/~3/vyVlsvLX_Ow/</link>
		<comments>http://sqlserverpedia.com/blog/sqlserverpedia-status-updates/sqlserverpedia-status-update-29th-july-2010/#comments</comments>
		<pubDate>Thu, 29 Jul 2010 12:28:38 +0000</pubDate>
		<dc:creator>IKick</dc:creator>
				<category><![CDATA[SQLServerPedia Status Updates]]></category>

		<guid isPermaLink="false">http://sqlserverpedia.com/blog/?p=29237</guid>
		<description><![CDATA[Firstly, welcome to lots of new bloggers, check them out on our Bloggers page. The rate at which new requests to syndicate have come in has certainly surprised and amazed me! Many thanks.
There have been a few changes to the site you may have noticed recently:

Contact Address
We’ve changed ask@sqlserverpedia.com to hello@sqlserverpedia.com, please use this address [...]]]></description>
			<content:encoded><![CDATA[<p>Firstly, welcome to lots of new bloggers, check them out on our <a href="http://sqlserverpedia.com/wiki/Bloggers">Bloggers</a> page. The rate at which new requests to syndicate have come in has certainly surprised and amazed me! Many thanks.</p>
<p>There have been a few changes to the site you may have noticed recently:<br />
<br />
<h2>Contact Address</h2>
<p>We’ve changed <a href="mailto:ask@sqlserverpedia.com">ask@sqlserverpedia.com</a> to <a href="mailto:hello@sqlserverpedia.com">hello@sqlserverpedia.com</a>, please use this address from here on.<br />
<br />
<h2>Blog Categories</h2>
<p>Brett Epps has added new sections to the blog menu. A lot of you have been writing articles about <strong>Professional Development</strong>, so whilst these aren’t specific to SQL Server they are certainly relevant to the users of the site. We have always wanted to keep the main blog focussed on SQL Server content so we have separated these posts to a <a href="http://sqlserverpedia.com/blog/category/professional-development/">Professional Development</a> blog page. You can post to this page by creating a ‘Professional Development’ category on your blog and putting the posts in both the normal syndication category you use for the feed and the new one. The site will filter as necessary.</p>
<p>For those using Blogger, which doesn’t support categories, just label your relevant posts ‘Professional Development’.</p>
<p>There is a section for <a href="http://sqlserverpedia.com/blog/category/database-design/">Database Design</a> – category name ‘Database Design’, and a section for <a href="http://sqlserverpedia.com/blog/category/podcasts/">Podcasts</a>.</p>
<p>We are looking at creating a Wiki section for these articles as well.</p>
<p>We also have a <a href="http://sqlserverpedia.com/blog/category/sqlserverpedia-status-updates/">Site Updates</a> section where you can see this and previous SQLServerPedia Status Updates.</p>
<p>If there are other section topics you feel would be relevant please let us know.<br />
<br />
<h2>Buzz is renamed to Pulse</h2>
<p>For those unfamiliar with <a href="http://pulse.sqlserverpedia.com/stream/list">Pulse</a>, it searches relevant topics on Twitter and Delicious so users can find the current topics under discussion in the community. You can vote for favourite topics (or just your own!) so other users will see them listed first.</p>
<p>Here is a listing of the current search terms we are using. If there are others you feel are relevant please let us know:</p>
<p> <a href="http://www.twitter.com/">Twitter</a>:</p>
<ul>
<li>&#8220;sql server&#8221;</li>
<li>&#8220;sql 2005&#8243;</li>
<li>&#8220;sql 2008&#8243;</li>
<li>t-sql</li>
<li>tsql</li>
<li>#sqlhelp</li>
<li>“microsoft dba”</li>
<li>@sqlserverpedia</li>
<li>to:sqlserverpedia</li>
<li>#sqlserverpediatraining</li>
</ul>
<p> <a href="http://delicious.com/">Delicious</a>:</p>
<ul>
<li>sqlserver</li>
<li>tsql</li>
<li>sql2000</li>
<li>sql2005</li>
<li>sql2008</li>
</ul>
<p>  </p>
<h2>Update Statistics</h2>
<p>Some interesting stats:</p>
<ul>
<li> SQLServerPedia has <strong>66</strong> bloggers contributing</li>
<li> SQLServerPedia has over <strong>3,400</strong> blog posts containing over <strong>two million</strong> words of content.</li>
<li> SQLServerPedia Pulse has nearly <strong>100,000</strong> items in its content database.</li>
<li> Monday-Thursday we average <strong>9,000+</strong> visits and had a day last week with <strong>9,904</strong>! Lesson here, don’t post on a Friday or the weekend!</li>
</ul>
<p>  </p>
<h2>Wiki</h2>
<p>I have updated the <a href="http://sqlserverpedia.com/wiki/TempDB">TempDB</a> wiki page, please edit as you feel it appropriate. We are really keen for you guys to update the wiki pages. If you prefer send us the blog post around the subject and we will do the editing for the wiki as necessary.</p>




	<a rel="nofollow"  href="http://digg.com/submit?phase=2&amp;url=http%3A%2F%2Fsqlserverpedia.com%2Fblog%2Fsqlserverpedia-status-updates%2Fsqlserverpedia-status-update-29th-july-2010%2F&amp;title=SQLServerPedia%20Status%20Update%20-%2029th%20July%202010&amp;bodytext=Firstly%2C%20welcome%20to%20lots%20of%20new%20bloggers%2C%20check%20them%20out%20on%20our%20Bloggers%20page.%20The%20rate%20at%20which%20new%20requests%20to%20syndicate%20have%20come%20in%20has%20certainly%20surprised%20and%20amazed%20me%21%20Many%20thanks.%0D%0A%0D%0AThere%20have%20been%20a%20few%20changes%20to%20the%20site%20you%20may%20have%20noti" title="Digg"><img src="http://sqlserverpedia.com/blog/wp-content/plugins/sociable/images/digg.png" title="Digg" alt="Digg" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://delicious.com/post?url=http%3A%2F%2Fsqlserverpedia.com%2Fblog%2Fsqlserverpedia-status-updates%2Fsqlserverpedia-status-update-29th-july-2010%2F&amp;title=SQLServerPedia%20Status%20Update%20-%2029th%20July%202010&amp;notes=Firstly%2C%20welcome%20to%20lots%20of%20new%20bloggers%2C%20check%20them%20out%20on%20our%20Bloggers%20page.%20The%20rate%20at%20which%20new%20requests%20to%20syndicate%20have%20come%20in%20has%20certainly%20surprised%20and%20amazed%20me%21%20Many%20thanks.%0D%0A%0D%0AThere%20have%20been%20a%20few%20changes%20to%20the%20site%20you%20may%20have%20noti" title="del.icio.us"><img src="http://sqlserverpedia.com/blog/wp-content/plugins/sociable/images/delicious.png" title="del.icio.us" alt="del.icio.us" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://www.dzone.com/links/add.html?url=http%3A%2F%2Fsqlserverpedia.com%2Fblog%2Fsqlserverpedia-status-updates%2Fsqlserverpedia-status-update-29th-july-2010%2F&amp;title=SQLServerPedia%20Status%20Update%20-%2029th%20July%202010" title="DZone"><img src="http://sqlserverpedia.com/blog/wp-content/plugins/sociable/images/dzone.png" title="DZone" alt="DZone" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://www.dotnetkicks.com/kick/?url=http%3A%2F%2Fsqlserverpedia.com%2Fblog%2Fsqlserverpedia-status-updates%2Fsqlserverpedia-status-update-29th-july-2010%2F&amp;title=SQLServerPedia%20Status%20Update%20-%2029th%20July%202010" title="DotNetKicks"><img src="http://sqlserverpedia.com/blog/wp-content/plugins/sociable/images/dotnetkicks.png" title="DotNetKicks" alt="DotNetKicks" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://www.google.com/bookmarks/mark?op=edit&amp;bkmk=http%3A%2F%2Fsqlserverpedia.com%2Fblog%2Fsqlserverpedia-status-updates%2Fsqlserverpedia-status-update-29th-july-2010%2F&amp;title=SQLServerPedia%20Status%20Update%20-%2029th%20July%202010&amp;annotation=Firstly%2C%20welcome%20to%20lots%20of%20new%20bloggers%2C%20check%20them%20out%20on%20our%20Bloggers%20page.%20The%20rate%20at%20which%20new%20requests%20to%20syndicate%20have%20come%20in%20has%20certainly%20surprised%20and%20amazed%20me%21%20Many%20thanks.%0D%0A%0D%0AThere%20have%20been%20a%20few%20changes%20to%20the%20site%20you%20may%20have%20noti" title="Google Bookmarks"><img src="http://sqlserverpedia.com/blog/wp-content/plugins/sociable/images/googlebookmark.png" title="Google Bookmarks" alt="Google Bookmarks" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://ping.fm/ref/?link=http%3A%2F%2Fsqlserverpedia.com%2Fblog%2Fsqlserverpedia-status-updates%2Fsqlserverpedia-status-update-29th-july-2010%2F&amp;title=SQLServerPedia%20Status%20Update%20-%2029th%20July%202010&amp;body=Firstly%2C%20welcome%20to%20lots%20of%20new%20bloggers%2C%20check%20them%20out%20on%20our%20Bloggers%20page.%20The%20rate%20at%20which%20new%20requests%20to%20syndicate%20have%20come%20in%20has%20certainly%20surprised%20and%20amazed%20me%21%20Many%20thanks.%0D%0A%0D%0AThere%20have%20been%20a%20few%20changes%20to%20the%20site%20you%20may%20have%20noti" title="Ping.fm"><img src="http://sqlserverpedia.com/blog/wp-content/plugins/sociable/images/ping.png" title="Ping.fm" alt="Ping.fm" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://reddit.com/submit?url=http%3A%2F%2Fsqlserverpedia.com%2Fblog%2Fsqlserverpedia-status-updates%2Fsqlserverpedia-status-update-29th-july-2010%2F&amp;title=SQLServerPedia%20Status%20Update%20-%2029th%20July%202010" title="Reddit"><img src="http://sqlserverpedia.com/blog/wp-content/plugins/sociable/images/reddit.png" title="Reddit" alt="Reddit" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://www.stumbleupon.com/submit?url=http%3A%2F%2Fsqlserverpedia.com%2Fblog%2Fsqlserverpedia-status-updates%2Fsqlserverpedia-status-update-29th-july-2010%2F&amp;title=SQLServerPedia%20Status%20Update%20-%2029th%20July%202010" title="StumbleUpon"><img src="http://sqlserverpedia.com/blog/wp-content/plugins/sociable/images/stumbleupon.png" title="StumbleUpon" alt="StumbleUpon" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="" title="TwitThis"><img src="http://sqlserverpedia.com/blog/wp-content/plugins/sociable/images/" title="TwitThis" alt="TwitThis" class="sociable-hovers" /></a>


<br/><br/><div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/sqlserverpedia?a=vyVlsvLX_Ow:uE6XxUUyPfs:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/sqlserverpedia?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/sqlserverpedia?a=vyVlsvLX_Ow:uE6XxUUyPfs:G79ilh31hkQ"><img src="http://feeds.feedburner.com/~ff/sqlserverpedia?d=G79ilh31hkQ" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/sqlserverpedia?a=vyVlsvLX_Ow:uE6XxUUyPfs:YwkR-u9nhCs"><img src="http://feeds.feedburner.com/~ff/sqlserverpedia?d=YwkR-u9nhCs" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/sqlserverpedia/~4/vyVlsvLX_Ow" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://sqlserverpedia.com/blog/sqlserverpedia-status-updates/sqlserverpedia-status-update-29th-july-2010/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://sqlserverpedia.com/blog/sqlserverpedia-status-updates/sqlserverpedia-status-update-29th-july-2010/</feedburner:origLink></item>
		<item>
		<title>Running a query against multiple servers at one</title>
		<link>http://feedproxy.google.com/~r/sqlserverpedia/~3/_3SL2nOwkBY/</link>
		<comments>http://sqlserverpedia.com/blog/sql-server-2008/running-a-query-against-multiple-servers-at-one/#comments</comments>
		<pubDate>Thu, 29 Jul 2010 11:00:36 +0000</pubDate>
		<dc:creator>Denny Cherry</dc:creator>
				<category><![CDATA[SQL Server 2008]]></category>
		<category><![CDATA[SQL Server Bloggers]]></category>

		<guid isPermaLink="false">http://itknowledgeexchange.techtarget.com/sql-server/running-a-query-against-multiple-servers-at-one/</guid>
		<description><![CDATA[So you&#8217;ve got a bunch of machines that you want to run a quick query against.  SQL Server 2008&#8217;s Management Studio gives you a quick and easy.  Open up the Registered Servers in Management Studio and select a group of servers.  Then right click on the group and click on the &#8220;New Query&#8221; option.

This will [...]]]></description>
			<content:encoded><![CDATA[<p>So you&#8217;ve got a bunch of machines that you want to run a quick query against.  SQL Server 2008&#8217;s Management Studio gives you a quick and easy.  Open up the Registered Servers in Management Studio and select a group of servers.  Then right click on the group and click on the &#8220;New Query&#8221; option.</p>
<p><a href="http://http.cdnlayer.com/itke/blogs.dir/20/files/2010/05/regestered_servers.jpg"><img class="alignnone size-medium wp-image-1146" src="http://http.cdnlayer.com/itke/blogs.dir/20/files/2010/05/regestered_servers.jpg" alt="" width="360" height="372" /></a></p>
<p>This will open a new query window where you can run a query against all the servers that are online in that group. In my sample query shown below you&#8217;ll see that I ran SELECT @@VERSION against all the servers.  When I ran this 3 of the 6 servers in the group were online so three servers were able to return data.</p>
<p><a href="http://http.cdnlayer.com/itke/blogs.dir/20/files/2010/05/ssms.jpg"><img class="alignnone size-thumbnail wp-image-1147" src="http://http.cdnlayer.com/itke/blogs.dir/20/files/2010/05/ssms.jpg" alt="" width="128" height="73" /></a></p>
<p>Now if you look at the messages tab (look down) you&#8217;ll see which servers the query ran against, and which servers it failed against.  It also tells you what accounts the query was run using (based on the connection info for each server).</p>
<p><a href="http://http.cdnlayer.com/itke/blogs.dir/20/files/2010/05/messages.jpg"><img class="alignnone size-thumbnail wp-image-1148" src="http://http.cdnlayer.com/itke/blogs.dir/20/files/2010/05/messages.jpg" alt="" width="128" height="33" /></a></p>
<p>Now you can&#8217;t merge data together in a temp table as everything in the query window will be run against each server.  It simply displays the information together.  You can pull a single value like I showed above, or you can query a table.</p>
<p><a href="http://http.cdnlayer.com/itke/blogs.dir/20/files/2010/05/ssms1.jpg"><img class="alignnone size-thumbnail wp-image-1149" src="http://http.cdnlayer.com/itke/blogs.dir/20/files/2010/05/ssms1.jpg" alt="" width="128" height="73" /></a></p>
<p>Now when querying from a tables on multiple servers you&#8217;ll need to make sure that the schema for those tables are identical otherwise it will only return the data for the first table that it queries.  An error will be shown on the messages tab telling that you that the schemas don&#8217;t match if this is the problem.</p>
<p>Denny</p>
<p><img src="http://feedproxy.google.com/Users/dcherry/AppData/Local/Temp/moz-screenshot.png" alt="" /></p>
<img src="http://feeds.feedburner.com/~r/SqlServerWithMrDenny/~4/4QC3-GHsDEo" height="1" width="1"/><div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/sqlserverpedia?a=_3SL2nOwkBY:4QC3-GHsDEo:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/sqlserverpedia?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/sqlserverpedia?a=_3SL2nOwkBY:4QC3-GHsDEo:G79ilh31hkQ"><img src="http://feeds.feedburner.com/~ff/sqlserverpedia?d=G79ilh31hkQ" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/sqlserverpedia?a=_3SL2nOwkBY:4QC3-GHsDEo:YwkR-u9nhCs"><img src="http://feeds.feedburner.com/~ff/sqlserverpedia?d=YwkR-u9nhCs" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/sqlserverpedia/~4/_3SL2nOwkBY" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://sqlserverpedia.com/blog/sql-server-2008/running-a-query-against-multiple-servers-at-one/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://sqlserverpedia.com/blog/sql-server-2008/running-a-query-against-multiple-servers-at-one/</feedburner:origLink></item>
		<item>
		<title>The Dangers of Sub-queries!!!!</title>
		<link>http://feedproxy.google.com/~r/sqlserverpedia/~3/bz46sQuvOK0/</link>
		<comments>http://sqlserverpedia.com/blog/sql-server-bloggers/the-dangers-of-sub-queries/#comments</comments>
		<pubDate>Thu, 29 Jul 2010 00:11:49 +0000</pubDate>
		<dc:creator>Wes Brown</dc:creator>
				<category><![CDATA[SQL Server Bloggers]]></category>

		<guid isPermaLink="false">https://sqlserverio.wordpress.com/?p=133</guid>
		<description><![CDATA[Ok, now that I have your attention this really should be titled the danger of not qualifying all objects, but that isn’t quite as sensational enough to make you click through to here Imagine if you will, a developer expects ten records to be inserted into a table and the query has been running for [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=sqlserverio.com&#38;blog=10834953&#38;post=133&#38;subd=sqlserverio&#38;ref=&#38;feed=1" />]]></description>
			<content:encoded><![CDATA[<p>Ok, now that I have your attention this really should be titled the danger of not qualifying all objects, but that isn’t quite as sensational enough to make you click through to here <img src='http://s.wordpress.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p>Imagine if you will, a developer expects ten records to be inserted into a table and the query has been running for almost an hour.&#160; A quick glance and sp_who2 shows that it is using a lot of IO, I mean a lot. The first thing that happens is a command decision from the boss to kill the query. I took a quick peek and found the plan still in the plan cache while we waited for this thing to roll back. As I look at the plan I see something really wrong. It looks like the table receiving the inserts isn’t getting the ten records we thought but 169 million records, every record from the table in the select clause. </p>
<p>I look at the query and on the surface everything looks good. When I hit the check mark it compiles without error. Looking at the plan in detail I notice a little icon that tipped me off on where to look next.</p>
<p><a href="http://sqlserverio.files.wordpress.com/2010/07/image1.png"><img style="display:block;float:none;margin-left:auto;margin-right:auto;border-width:0;" title="image" border="0" alt="image" src="http://sqlserverio.files.wordpress.com/2010/07/image_thumb1.png?w=118&#038;h=83" width="118" height="83" /></a></p>
<p>Oh that’s bad. Warnings: No join predicate. Ouch. But this is a sub-query, how can I have no join predicate? Lets take a look at an example.</p>
<pre class="brush:tsql">DROP TABLE #t1
DROP TABLE #t2
GO
CREATE TABLE #t1 (
  t1id    INT   NOT NULL,
  t1name  VARCHAR(50)   NULL,
  t1place VARCHAR(50)   NULL)

ALTER TABLE #t1
 ADD   PRIMARY KEY ( t1id )

CREATE TABLE #t2 (
  t2id    INT   NOT NULL,
  t1name  VARCHAR(50)   NULL,
  t1place VARCHAR(50)   NULL)

ALTER TABLE #t2
 ADD   PRIMARY KEY ( t2id )

INSERT INTO #t1
SELECT
  spid,
  loginame,
  hostname
FROM
  MASTER.dbo.sysprocesses
WHERE  hostname &lt;&gt; ''

INSERT INTO #t2
SELECT
  spid,
  loginame,
  hostname
FROM
  MASTER.dbo.sysprocesses
WHERE  hostname &lt;&gt; ''</pre>
<p>This gives us two tables with some data. We want to find all the records in #t1 that also exist in #t2 but instead of a join we will use an IN and a sub-query.</p>
<pre class="brush:tsql">SELECT
  t1name,
  t1place
FROM
  #t1
WHERE  t1id IN (SELECT
                 t1id
                FROM
                 #t2)</pre>
<pre class="brush:tsql">&#160;</pre>
<p>Looks simple enough and will pass the compile test all day long even though t1id doesn’t exist in #t2. Since you can use columns from the top level query in the sub-query this is a perfectly valid piece of T-SQL. </p>
<p>It gives us this plan when we look at it though.<a href="http://sqlserverio.files.wordpress.com/2010/07/image2.png"></a></p>
<p><a href="http://sqlserverio.files.wordpress.com/2010/07/image2.png"></a><img style="display:block;float:none;margin-left:auto;margin-right:auto;border-width:0;" title="image" border="0" alt="image" src="http://sqlserverio.files.wordpress.com/2010/07/image_thumb2.png?w=589&#038;h=188" width="589" height="188" /></p>
<p></a></p>
<p>And there you have it, a join without an ON clause as far as the optimizer is concerned. By not qualifying all the columns in the sub-query we opened ourselves up to this error. This isn’t the optimizers fault! If we re-write this as it was mean to be:</p>
<pre class="brush:tsql">SELECT
  t1name,
  t1place
FROM
  #t1
WHERE  t1id IN (SELECT
                 t2id
                FROM
                 #t2)</pre>
<pre class="brush:tsql">&#160;</pre>
<p>We get a plan that is more to our liking.</p>
<p><a href="http://sqlserverio.files.wordpress.com/2010/07/image3.png"><img style="display:block;float:none;margin-left:auto;margin-right:auto;border-width:0;" title="image" border="0" alt="image" src="http://sqlserverio.files.wordpress.com/2010/07/image_thumb3.png?w=562&#038;h=185" width="562" height="185" /></a> </p>
<p>You could also re-write this as a join instead of using the IN clause and would have avoided this problem as well. Scary way to learn that SQL Server will do <em>exactly</em> what you tell it to even if you are wrong!</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/sqlserverio.wordpress.com/133/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/sqlserverio.wordpress.com/133/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/sqlserverio.wordpress.com/133/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/sqlserverio.wordpress.com/133/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/sqlserverio.wordpress.com/133/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/sqlserverio.wordpress.com/133/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/sqlserverio.wordpress.com/133/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/sqlserverio.wordpress.com/133/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/sqlserverio.wordpress.com/133/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/sqlserverio.wordpress.com/133/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=sqlserverio.com&blog=10834953&post=133&subd=sqlserverio&ref=&feed=1" /><img src="http://feeds.feedburner.com/~r/SqlServerInput/outputSqlserverpediaSyndication/~4/9laFhOmCbCA" height="1" width="1"/><div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/sqlserverpedia?a=bz46sQuvOK0:pBhGIc6VqFg:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/sqlserverpedia?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/sqlserverpedia?a=bz46sQuvOK0:pBhGIc6VqFg:G79ilh31hkQ"><img src="http://feeds.feedburner.com/~ff/sqlserverpedia?d=G79ilh31hkQ" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/sqlserverpedia?a=bz46sQuvOK0:pBhGIc6VqFg:YwkR-u9nhCs"><img src="http://feeds.feedburner.com/~ff/sqlserverpedia?d=YwkR-u9nhCs" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/sqlserverpedia/~4/bz46sQuvOK0" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://sqlserverpedia.com/blog/sql-server-bloggers/the-dangers-of-sub-queries/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>

<enclosure url="http://0.gravatar.com/avatar/c42e9006feb3dd5ed4d463589a1d183e?s=96&amp;amp;d=identicon&amp;amp;r=PG" length="" type="" />
<enclosure url="http://sqlserverio.files.wordpress.com/2010/07/image_thumb3.png" length="" type="" />
<enclosure url="http://sqlserverio.files.wordpress.com/2010/07/image_thumb1.png" length="" type="" />
		<feedburner:origLink>http://sqlserverpedia.com/blog/sql-server-bloggers/the-dangers-of-sub-queries/</feedburner:origLink><enclosure url="http://feedproxy.google.com/~r/sqlserverpedia/~5/Iy4alHmVlR0/image_thumb2.png" length="0" /><feedburner:origEnclosureLink>http://sqlserverio.files.wordpress.com/2010/07/image_thumb2.png</feedburner:origEnclosureLink></item>
		<item>
		<title>Who created that backup file?</title>
		<link>http://feedproxy.google.com/~r/sqlserverpedia/~3/c9bIu6lDOWA/</link>
		<comments>http://sqlserverpedia.com/blog/sql-server-bloggers/who-created-that-backup-file/#comments</comments>
		<pubDate>Wed, 28 Jul 2010 20:17:29 +0000</pubDate>
		<dc:creator>Pradeep Adiga</dc:creator>
				<category><![CDATA[SQL Server Bloggers]]></category>

		<guid isPermaLink="false">http://www.sqldbadiaries.com/?p=205</guid>
		<description><![CDATA[Today my day started with a drive full issue. That too a drive on which the tempdb was residing! Someone had kept some good old backup files on this drive, may be in an effort to clean up another drive. &#8230; <a href="http://www.sqldbadiaries.com/2010/07/29/who-created-that-backup-file/">Continue reading <span>&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p style="text-align: justify;">Today my day started with a drive full issue. That too a drive on which the tempdb was residing! Someone had kept some good old backup files on this drive, may be in an effort to clean up another drive.</p>
<p style="text-align: justify;">The question was whodunit? This was a good question. Even though we may not be able to track who copied it there, at least we can know who took the backup.</p>
<p style="text-align: justify;">The approach is even though very simple, but at times it is very useful. Yes, I am referring to <em>RESTORE HEADERONLY</em>&#8230;&#8230;.</p>
<p style="text-align: justify;">Restore Headeronly command gives the header information for a given backup set. The header contains some useful information like the Backup Type, User Name, Server/Database Name, Backup Start &amp; End Date etc. The syntax is something like</p>
<pre style="text-align: justify;" class="brush:tsql">RESTORE HEADERONLY FROM DISK = 'C:\GuessWhoDunit.bak'<p>and the output will be like</p>
<p><img src="file:/C%3A/DOCUME~1/ADMINI~1/LOCALS~1/Temp/moz-screenshot.png" alt="" /><a href="http://www.sqldbadiaries.com/wp-content/uploads/2010/07/headeronly.jpg"><img class="alignnone size-full wp-image-206" title="headeronly" src="http://www.sqldbadiaries.com/wp-content/uploads/2010/07/headeronly.jpg" alt="" width="402" height="37" /></a></p>
<p>In my case, it turned out that the backup was taken using SQL Server Agent and the user name was the service account !</p>
<p>Even though this exercise did not give the expected results, it was good to put in use one of the DBA friendly commands.</p>
<div id="flaresmith" class="feedflare"><script src="http://feedproxy.google.com/~s/SqlDbaDiaries?i=http://www.sqldbadiaries.com/2010/07/29/who-created-that-backup-file/" type="text/javascript" charset="utf-8"></script></div><div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/PradeepAdigaSQLServerPedia?a=mcInt9BDStE:DLghI3AjW4Y:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/PradeepAdigaSQLServerPedia?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/PradeepAdigaSQLServerPedia?a=mcInt9BDStE:DLghI3AjW4Y:7Q72WNTAKBA"><img src="http://feeds.feedburner.com/~ff/PradeepAdigaSQLServerPedia?d=7Q72WNTAKBA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/PradeepAdigaSQLServerPedia?a=mcInt9BDStE:DLghI3AjW4Y:V_sGLiPBpWU"><img src="http://feeds.feedburner.com/~ff/PradeepAdigaSQLServerPedia?i=mcInt9BDStE:DLghI3AjW4Y:V_sGLiPBpWU" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/PradeepAdigaSQLServerPedia?a=mcInt9BDStE:DLghI3AjW4Y:3QFJfmc7Om4"><img src="http://feeds.feedburner.com/~ff/PradeepAdigaSQLServerPedia?i=mcInt9BDStE:DLghI3AjW4Y:3QFJfmc7Om4" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/PradeepAdigaSQLServerPedia/~4/mcInt9BDStE" height="1" width="1"/><div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/sqlserverpedia?a=c9bIu6lDOWA:DLghI3AjW4Y:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/sqlserverpedia?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/sqlserverpedia?a=c9bIu6lDOWA:DLghI3AjW4Y:G79ilh31hkQ"><img src="http://feeds.feedburner.com/~ff/sqlserverpedia?d=G79ilh31hkQ" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/sqlserverpedia?a=c9bIu6lDOWA:DLghI3AjW4Y:YwkR-u9nhCs"><img src="http://feeds.feedburner.com/~ff/sqlserverpedia?d=YwkR-u9nhCs" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/sqlserverpedia/~4/c9bIu6lDOWA" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://sqlserverpedia.com/blog/sql-server-bloggers/who-created-that-backup-file/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://sqlserverpedia.com/blog/sql-server-bloggers/who-created-that-backup-file/</feedburner:origLink></item>
		<item>
		<title>The Right Level of “Right”</title>
		<link>http://feedproxy.google.com/~r/sqlserverpedia/~3/sXKsjvXXKGA/</link>
		<comments>http://sqlserverpedia.com/blog/sql-server-bloggers/the-right-level-of-%e2%80%9cright%e2%80%9d/#comments</comments>
		<pubDate>Wed, 28 Jul 2010 17:47:10 +0000</pubDate>
		<dc:creator>Jen McCown</dc:creator>
				<category><![CDATA[SQL Server Bloggers]]></category>

		<guid isPermaLink="false">http://www.midnightdba.com/Jen/?p=725</guid>
		<description><![CDATA[&#8230;or, How I Learned to Stop Worrying and Love the Bomb I had a SQL dev&#8217;s dream come to me via email yesterday: a high-urgency, high-profile request for data that was both interesting and doable. I spent a few hours on it last night and this morning, and handed over a beautiful solution that was [...]]]></description>
			<content:encoded><![CDATA[<h2>&#8230;or, How I Learned to Stop Worrying and Love the Bomb</h2>
<p>I had a SQL dev&#8217;s dream come to me via email yesterday: a high-urgency, high-profile request for data that was both interesting and doable. I spent a few hours on it last night and this morning, and handed over a beautiful solution that was well appreciated.  The end. </p>
<div id="attachment_728" class="wp-caption alignright" style="width: 360px"><a href="http://www.flickr.com/photos/good_day/319849055/"><img class="size-full wp-image-728" title="shinythings_Today is a good day_flickr" src="http://www.midnightdba.com/Jen/wp-content/uploads/2010/07/shinythings_Today-is-a-good-day_flickr.jpg" alt="Courtesy &quot;Today is a good day&quot; on Flickr" width="350" height="234" /></a><p class="wp-caption-text">Shiny!</p></div>
<p>Well, not really the end. This task made me think hard about the right level of &#8220;right&#8221;. Of course there&#8217;s more than one wrong way to retrieve data: for example, anything that wastes massive effort or resources, or comes back incomplete or otherwise incorrect.  But there&#8217;s a balance to all things&#8230; in this case, a balance between &#8220;BEST POSSIBLE SOLUTION&#8221; and &#8220;slapped-together piece of nearly unusable crap &#8220;.  We&#8217;re too often pushed toward the latter by time constraints and demanding situations, but we can also be lured into unproductivity by the shiny shinyness of the former. </p>
<p>What the hell am I talking about? I&#8217;ll tell you. </p>
<p>To take the example of my task: It was a request for two spreadsheets representing data from 2010 and 2009&#8230;a moderately complicated pivot of (real-life) entities and events, and which participated in which. The way the data was structured, I had a few options: </p>
<h3>1. Best Solution</h3>
<p>The absolute best solution (or, <em>one </em>of the best solutions) would be to </p>
<ol>
<li>Set up a user-defined table datatype of event keys, and declare an @Event table of that type (to be passed into a stored procedure).</li>
<li>Write the SP with some dynamic SQL to create and populate a #temp table using participant Entity data JOINed to the @Event parameter table, and a final select out. </li>
<li>Bust out an SSRS report to use that SP, and set all that up in our user interface to  be called on demand, or schedule it to run monthly and publish to a shared folder.</li>
</ol>
<p>For this particular solution, the dynamic SQL would&#8217;ve kicked my butt for too long, and the report would&#8217;ve taken (in my opinion) more time than it&#8217;s worth. Plus, we have other considerations: the SP should really be flexible enough to produce this report, or allow for a report on a single Entity&#8217;s participation in Events; that&#8217;s another layer of complexity. Finally, this is a report that won&#8217;t run often: <em>maybe </em>twice a year, in my estimation.  That&#8217;s an awful lot of time to spend on a setup that the users need NOW NOW NOW. </p>
<h3>2. Crap Solution</h3>
<p>Create a manual pivot SELECT statement, based on the events needed. This is a horrible solution: while it&#8217;d probably be significantly faster than the Best Solution above, it&#8217;s be a huge pain in the butt, and it would have to be done for the 2010 data, and redone for the 2009 data, AND redone any time someone wants to rerun for 2010 data (events are still being added this year, you know).  The simplest solution, even in a quick-fire situation like this, is not always the <em>best </em>solution. </p>
<h3>3. Middle Ground</h3>
<p>My solution was a temporary table of event keys, a manually created &#8220;pivot&#8221; temp table, and a cursor to update it for each event column. THAT&#8217;S RIGHT,  A CURSOR!  Cursors shouldn&#8217;t be part of your everyday code, absolutely. But sometimes they are beneficial, and have a minimal impact. This was such a time: it simlpified and quickened my development cycle, had a minimal impact (cycling through 114 repetitions, not millions), and isn&#8217;t at all likely to be used often (no more than twice a year max). </p>
<p>Several of you just blew a gasket, because this isn&#8217;t something you would have done. I understand, and I&#8217;m with you&#8230;but there&#8217;s right, there&#8217;s wrong, and then there&#8217;s the right level of right. </p>
<p>Happy days, </p>
<p>Jen McCown </p>
<p><a href="http://www.midnightdba.com">http://www.MidnightDBA.com</a></p>
<div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/sqlserverpedia?a=sXKsjvXXKGA:oasTErltDD8:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/sqlserverpedia?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/sqlserverpedia?a=sXKsjvXXKGA:oasTErltDD8:G79ilh31hkQ"><img src="http://feeds.feedburner.com/~ff/sqlserverpedia?d=G79ilh31hkQ" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/sqlserverpedia?a=sXKsjvXXKGA:oasTErltDD8:YwkR-u9nhCs"><img src="http://feeds.feedburner.com/~ff/sqlserverpedia?d=YwkR-u9nhCs" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/sqlserverpedia/~4/sXKsjvXXKGA" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://sqlserverpedia.com/blog/sql-server-bloggers/the-right-level-of-%e2%80%9cright%e2%80%9d/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://sqlserverpedia.com/blog/sql-server-bloggers/the-right-level-of-%e2%80%9cright%e2%80%9d/</feedburner:origLink></item>
	</channel>
</rss><!-- Dynamic page generated in 0.509 seconds. --><!-- Cached page generated by WP-Super-Cache on 2010-07-29 16:32:22 -->
