<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" media="screen" href="/~d/styles/rss2full.xsl"?><?xml-stylesheet type="text/css" media="screen" href="http://feeds.feedburner.com/~d/styles/itemcontent.css"?><rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:sy="http://purl.org/rss/1.0/modules/syndication/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:feedburner="http://rssnamespace.org/feedburner/ext/1.0" version="2.0">

<channel>
	<title>theReal MikeNelson</title>
	
	<link>http://therealmikenelson.com/wordpress</link>
	<description>Just another WordPress weblog</description>
	<lastBuildDate>Sun, 20 Dec 2009 23:57:18 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.6</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/theRealMikeNelson" /><feedburner:info uri="therealmikenelson" /><atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="hub" href="http://pubsubhubbub.appspot.com/" /><item>
		<title>WHERE did this data come from?</title>
		<link>http://feedproxy.google.com/~r/theRealMikeNelson/~3/IEn9G28dq1w/</link>
		<comments>http://therealmikenelson.com/wordpress/2009/12/where-did-this-come-from/#comments</comments>
		<pubDate>Sun, 20 Dec 2009 16:23:20 +0000</pubDate>
		<dc:creator>TRMNDC</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://therealmikenelson.com/wordpress/2009/12/where-did-this-come-from/</guid>
		<description><![CDATA[Just the facts, ma&#8217;am
This is a late entry for T-SQL Tuesday #001 (Date/Time Tricks).
One of the consistencies over my several decades in IT has been how most of us IT professionals are very good at retrieving bits of arcane data as required to demonstrate a point. What we (myself included) seem not to be so ]]></description>
			<content:encoded><![CDATA[<h3>Just the facts, ma&#8217;am</h3>
<h6>This is a late entry for <a title="http://sqlblog.com/blogs/adam_machanic/archive/2009/12/09/t-sql-tuesday-001-the-roundup.aspx" href="http://sqlblog.com/blogs/adam_machanic/archive/2009/12/09/t-sql-tuesday-001-the-roundup.aspx">T-SQL Tuesday #001 (Date/Time Tricks)</a>.</h6>
<p>One of the consistencies over my several decades in IT has been how most of us IT professionals are very good at retrieving bits of arcane data as required to demonstrate a point. What we (myself included) seem not to be so good at is keeping track of where and when we got the piece of information.</p>
<p>In countless conversations with entrenched developers I have had to prove, over and over to them, details surrounding data from a database. Testers would run a series of tests, expecting X in the database and the results either were not there or the data in the database was Y. The most common response over the decades has been “You are not looking at the correct database.”</p>
<p>More than a decade ago, after one such disagreement, I decided to write a stored procedure that I could call from anywhere and could demonstrate precisely the server and database from which the data was retrieved as well as the time. The result was one of the most useful procedures I have ever written, sp_Stamp. I typically call sp_Stamp from most procs I write that are designed to produce a result set for possible distribution so the ambiguity of where and when I gathered the data presented are clarified at the outset.</p>
<p>The premise is quite simple; provide the date, time, server and database as part of the result set. End of argument.</p>
<p>Below is what the result looks like:</p>
<p>sp_Stamp was run on Saturday, Dec 5 2009 1:40:09:007PM.</p>
<p>This SCRIPT is being run against SERVER.DATABASE: SQL2008TEST.OperationsManager</p>
<p>Like every script I write, it automatically performs it&#8217;s own UNIT TEST after the proc is created. It also contains my typical threats of DEATH and/or DISMEMBERMENT to junior DBAs who decide to mess with my code. This is NOT rocket science but it will sure save some arguments.</p>
<p>Here&#8217;s the SQL:</p>
<div><code style="font-size: 12px;"><span style="color:green">/*<br />
sp_Stamp.sql<br />
*/<br />
</span><span style="color:blue">USE MASTER </span><span style="color:green">-- &lt;------- USE master for this SYSTEM LEVEL Stored Procedure.-----&lt;&lt;<br />
</span><span style="color:black">GO<br />
</span><span style="color:blue">IF </span><span style="color:gray">EXISTS (</span><span style="color:blue">SELECT </span><span style="color:gray">* </span><span style="color:blue">FROM </span><span style="color:black">sysobjects<br />
            </span><span style="color:blue">WHERE </span><span style="color:black">id </span><span style="color:blue">= </span><span style="color:magenta">OBJECT_ID</span><span style="color:gray">(</span><span style="color:red">'dbo.sp_Stamp'</span><span style="color:gray">)<br />
              AND </span><span style="color:black">sysstat </span><span style="color:gray">&amp;</span><span style="color:black">amp</span><span style="color:gray">; </span><span style="color:black">0xf </span><span style="color:blue">= </span><span style="color:black">4</span><span style="color:gray">)<br />
     </span><span style="color:blue">DROP PROCEDURE </span><span style="color:black">dbo.</span><span style="color:darkred">sp_Stamp<br />
</span><span style="color:black">GO<br />
</span><span style="color:green">/*<br />
********************************************************************************<br />
** USE master for this SYSTEM LEVEL Stored Procedure.  This allows this SP to **<br />
** be invoked from any Database on this Server.                               **<br />
********************************************************************************<br />
*/<br />
/*<br />
********************************************************************************<br />
** The step above ("if exists"), is automatically generated by SQL Server -<br />
** the procedure is droppped before recreation.  <br />
********************************************************************************<br />
*/<br />
/*<br />
********************************************************************************<br />
**<br />
** File:            sp_Stamp.sql<br />
**<br />
** Author:          Michael G. Nelson<br />
**<br />
** Description:     This SP adds Timestamp/SERVER:DATABASE output to the<br />
**                  SERVER OUTPUT.  The SP can be called by a script, a FRONT<br />
**                  END application or from a query in an ISQL or ISQLw<br />
**                  window.<br />
**<br />
** Called By:       Any number of other SPs and SQL Scripts<br />
**<br />
** SPs Called :     None<br />
**<br />
** Input<br />
**   Parameters:    None<br />
**<br />
** Creation Date:   01/22/99<br />
**<br />
** Modifications:<br />
**   (Date,    By,  Description)<br />
**   03/02/99  MGN  Added Comments.<br />
********************************************************************************<br />
*/<br />
/*<br />
********************************************************************************<br />
**                          DECLARE Input Parameters                          **<br />
********************************************************************************<br />
*/<br />
</span><span style="color:blue">CREATE PROCEDURE </span><span style="color:darkred">sp_Stamp<br />
</span><span style="color:green">/*<br />
********************************************************************************<br />
**                  DECLARE Stored Procedure Internal Variables               **<br />
********************************************************************************<br />
*/<br />
</span><span style="color:blue">AS<br />
DECLARE<br />
</span><span style="color:#434343">@ReturnMessage                     </span><span style="color:blue">VARCHAR</span><span style="color:gray">(</span><span style="color:black">255</span><span style="color:gray">) </span><span style="color:green">-- Used for display strings<br />
/*<br />
********************************************************************************<br />
**                             Procedure Body                                 **<br />
********************************************************************************<br />
*/<br />
/*<br />
********************************************************************************<br />
**                   Record the DATE/TIME this script runs                    **<br />
**                 and the SERVER.DATABASE on which it was run                **<br />
********************************************************************************<br />
*/<br />
</span><span style="color:blue">BEGIN<br />
SET NOCOUNT ON<br />
PRINT </span><span style="color:red">' '<br />
</span><span style="color:blue">SELECT </span><span style="color:#434343">@ReturnMessage </span><span style="color:blue">=<br />
        </span><span style="color:gray">(</span><span style="color:blue">SELECT </span><span style="color:red">'sp_Stamp was run on '<br />
        </span><span style="color:gray">+ </span><span style="color:magenta">CONVERT</span><span style="color:gray">(</span><span style="color:blue">VARCHAR</span><span style="color:gray">(</span><span style="color:black">19</span><span style="color:gray">),</span><span style="color:magenta">DATENAME</span><span style="color:gray">(</span><span style="color:black">dw</span><span style="color:gray">,</span><span style="color:magenta">GETDATE</span><span style="color:gray">()))<br />
        + </span><span style="color:red">', '<br />
        </span><span style="color:gray">+ </span><span style="color:magenta">CONVERT</span><span style="color:gray">(</span><span style="color:blue">VARCHAR</span><span style="color:gray">(</span><span style="color:black">40</span><span style="color:gray">),</span><span style="color:magenta">GETDATE</span><span style="color:gray">(),</span><span style="color:black">109</span><span style="color:gray">)<br />
        + </span><span style="color:red">'.'<br />
        </span><span style="color:gray">)<br />
</span><span style="color:blue">PRINT </span><span style="color:#434343">@ReturnMessage </span><span style="color:green">-- PRINTs when script was run<br />
</span><span style="color:blue">SELECT </span><span style="color:#434343">@ReturnMessage </span><span style="color:blue">=<br />
       </span><span style="color:gray">(</span><span style="color:blue">SELECT </span><span style="color:red">'This SCRIPT is being run against SERVER.DATABASE: '<br />
        </span><span style="color:gray">+ </span><span style="color:#434343">@@servername </span><span style="color:gray">+ </span><span style="color:red">'.' </span><span style="color:gray">+ </span><span style="color:magenta">DB_NAME</span><span style="color:gray">()<br />
        )<br />
</span><span style="color:blue">PRINT </span><span style="color:#434343">@ReturnMessage </span><span style="color:green">-- PRINTs the SERVER.DATABASE against which it was run<br />
</span><span style="color:blue">PRINT </span><span style="color:red">' '<br />
</span><span style="color:blue">SET NOCOUNT OFF<br />
</span><span style="color:green">/*<br />
********************************************************************************<br />
**                                Main Section                                **<br />
********************************************************************************<br />
*/<br />
</span><span style="color:blue">END<br />
</span><span style="color:green">/*<br />
********************************************************************************<br />
**                                 Make Grants                                **<br />
**        ----&gt;       Make SURE the GRANTs are APPROPRIATE!       &lt;----       **<br />
********************************************************************************<br />
*/<br />
</span><span style="color:black">GO                                          <br />
</span><span style="color:green">-- This GO Statement Creates the SP<br />
</span><span style="color:blue">PRINT </span><span style="color:red">'Make GRANTs'<br />
</span><span style="color:black">GO<br />
</span><span style="color:blue">GRANT  EXECUTE  ON </span><span style="color:black">dbo.</span><span style="color:darkred">sp_Stamp  </span><span style="color:blue">TO PUBLIC<br />
</span><span style="color:black">GO<br />
</span><span style="color:blue">PRINT </span><span style="color:red">'GRANTs complete!'<br />
</span><span style="color:black">GO<br />
</span><span style="color:green">/*<br />
********************************************************************************<br />
**                                 SP UNIT Test                               **<br />
********************************************************************************<br />
*/<br />
</span><span style="color:blue">IF </span><span style="color:gray">EXISTS (</span><span style="color:blue">SELECT </span><span style="color:gray">* </span><span style="color:blue">FROM </span><span style="color:black">sysobjects<br />
            </span><span style="color:blue">WHERE </span><span style="color:black">id </span><span style="color:blue">= </span><span style="color:magenta">OBJECT_ID</span><span style="color:gray">(</span><span style="color:red">'dbo.sp_Stamp'</span><span style="color:gray">)<br />
              AND </span><span style="color:black">sysstat </span><span style="color:gray">&amp;</span><span style="color:black">amp</span><span style="color:gray">; </span><span style="color:black">0xf </span><span style="color:blue">= </span><span style="color:black">4</span><span style="color:gray">)<br />
     </span><span style="color:blue">BEGIN<br />
      PRINT </span><span style="color:red">' '<br />
      </span><span style="color:blue">PRINT </span><span style="color:red">' '<br />
      </span><span style="color:blue">PRINT </span><span style="color:red">'################################################################################'<br />
      </span><span style="color:blue">PRINT </span><span style="color:red">'############################### BEGIN UNIT Test  ###############################'<br />
      </span><span style="color:blue">PRINT </span><span style="color:red">'################################################################################'<br />
      </span><span style="color:blue">PRINT </span><span style="color:red">' '<br />
      </span><span style="color:blue">PRINT </span><span style="color:red">' '<br />
      </span><span style="color:blue">PRINT </span><span style="color:red">'The following command will be EXECuted:'<br />
      </span><span style="color:blue">PRINT </span><span style="color:red">'EXEC sp_Stamp'<br />
       </span><span style="color:blue">EXEC </span><span style="color:darkred">sp_Stamp<br />
      </span><span style="color:blue">PRINT </span><span style="color:red">' '<br />
      </span><span style="color:blue">PRINT </span><span style="color:red">'################################################################################'<br />
      </span><span style="color:blue">PRINT </span><span style="color:red">'###############################   END UNIT Test  ###############################'<br />
      </span><span style="color:blue">PRINT </span><span style="color:red">'################################################################################'<br />
     </span><span style="color:blue">RETURN<br />
     END<br />
PRINT </span><span style="color:red">'################################################################################'<br />
</span><span style="color:blue">PRINT </span><span style="color:red">'################################   ERROR!!!  ###################################'<br />
</span><span style="color:blue">PRINT </span><span style="color:red">'################################   ERROR!!!  ###################################'<br />
</span><span style="color:blue">PRINT </span><span style="color:red">'################################   ERROR!!!  ###################################'<br />
</span><span style="color:blue">PRINT </span><span style="color:red">'################################   ERROR!!!  #############################'<br />
</span><span style="color:blue">PRINT </span><span style="color:red">'################################   ERROR!!!  ###################################'<br />
</span><span style="color:blue">PRINT </span><span style="color:red">'################################################################################'<br />
</span><span style="color:blue">PRINT </span><span style="color:red">' '<br />
</span><span style="color:blue">PRINT </span><span style="color:red">'Stored Procedure sp_Stamp DOES NOT EXIST IN THIS DATABASE!!!!'<br />
</span><span style="color:blue">PRINT </span><span style="color:red">' '<br />
</span><span style="color:blue">PRINT </span><span style="color:red">'UNIT Test ABORTED!!!!!!!'<br />
</span><span style="color:blue">PRINT </span><span style="color:red">' '<br />
</span><span style="color:blue">PRINT </span><span style="color:red">'################################################################################'<br />
</span><span style="color:blue">PRINT </span><span style="color:red">'################################   ERROR!!!  ###################################'<br />
</span><span style="color:blue">PRINT </span><span style="color:red">'################################################################################'<br />
</span><span style="color:black">GO</span></code></div>
<div><code style="font-size: 12px;"><span style="color:black"> </span></code></div>
<p><code style="font-size: 12px;"><span style="color:black"> </p>
<p></span></code></p>
<img src="http://feeds.feedburner.com/~r/theRealMikeNelson/~4/IEn9G28dq1w" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://therealmikenelson.com/wordpress/2009/12/where-did-this-come-from/feed/</wfw:commentRss>
		<slash:comments>7</slash:comments>
		<feedburner:origLink>http://therealmikenelson.com/wordpress/2009/12/where-did-this-come-from/</feedburner:origLink></item>
		<item>
		<title>I Wonder</title>
		<link>http://feedproxy.google.com/~r/theRealMikeNelson/~3/VFQOIcNLFtM/</link>
		<comments>http://therealmikenelson.com/wordpress/2009/12/i-wonder/#comments</comments>
		<pubDate>Sun, 20 Dec 2009 15:28:52 +0000</pubDate>
		<dc:creator>TRMNDC</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://therealmikenelson.com/wordpress/?p=3</guid>
		<description><![CDATA[Is Live Writer actually still working?
]]></description>
			<content:encoded><![CDATA[<p>Is Live Writer actually still working?</p>
<img src="http://feeds.feedburner.com/~r/theRealMikeNelson/~4/VFQOIcNLFtM" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://therealmikenelson.com/wordpress/2009/12/i-wonder/feed/</wfw:commentRss>
		<slash:comments>12</slash:comments>
		<feedburner:origLink>http://therealmikenelson.com/wordpress/2009/12/i-wonder/</feedburner:origLink></item>
		<item>
		<title>Hello world!</title>
		<link>http://feedproxy.google.com/~r/theRealMikeNelson/~3/qqcWgcX8Psg/</link>
		<comments>http://therealmikenelson.com/wordpress/2009/12/hello-world/#comments</comments>
		<pubDate>Sun, 13 Dec 2009 16:54:17 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http:/?p=1</guid>
		<description><![CDATA[Welcome to WordPress. This is your first post. Edit or delete it, then start blogging!
]]></description>
			<content:encoded><![CDATA[<p>Welcome to WordPress. This is your first post. Edit or delete it, then start blogging!</p>
<img src="http://feeds.feedburner.com/~r/theRealMikeNelson/~4/qqcWgcX8Psg" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://therealmikenelson.com/wordpress/2009/12/hello-world/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		<feedburner:origLink>http://therealmikenelson.com/wordpress/2009/12/hello-world/</feedburner:origLink></item>
	</channel>
</rss>
