<?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>SQLLawman</title>
	
	<link>http://www.deputyfamily.net/MichaelDeputy</link>
	<description>Family man and SQL Geek</description>
	<lastBuildDate>Tue, 31 Aug 2010 14:44:43 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.1</generator>
		<atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="self" type="application/rss+xml" href="http://feeds.feedburner.com/MichaelDeputy" /><feedburner:info uri="michaeldeputy" /><atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="hub" href="http://pubsubhubbub.appspot.com/" /><feedburner:emailServiceId>MichaelDeputy</feedburner:emailServiceId><feedburner:feedburnerHostname>http://feedburner.google.com</feedburner:feedburnerHostname><item>
		<title>Restoring Last Full Backup</title>
		<link>http://feedproxy.google.com/~r/MichaelDeputy/~3/NgpIcelPjDc/</link>
		<comments>http://www.deputyfamily.net/MichaelDeputy/archive/2010/08/restoring-last-full-backup/#comments</comments>
		<pubDate>Tue, 31 Aug 2010 14:44:43 +0000</pubDate>
		<dc:creator>MichaelDeputy</dc:creator>
				<category><![CDATA[MSSQL]]></category>
		<category><![CDATA[SQL Server]]></category>
		<category><![CDATA[t-sql]]></category>

		<guid isPermaLink="false">http://www.deputyfamily.net/MichaelDeputy/?p=276</guid>
		<description><![CDATA[I ran into a small problem where I needed to automate a restore of my last full backup to a different database.  Since my full backup file names include a date/time stamp I needed to query msdb for the backup name.  Since I figured it out, I thought I'd post it so I would know [...]]]></description>
			<content:encoded><![CDATA[<p>I ran into a small problem where I needed to automate a restore of my last full backup to a different database.  Since my full backup file names include a date/time stamp I needed to query msdb for the backup name.  Since I figured it out, I thought I'd post it so I would know where of find it the next time I need it, and maybe help someone else out in the process.</p>
<p>declare @bksource varchar(100)<br />
select @bksource=(<br />
select a.physical_device_name<br />
from [msdb].[dbo].[backupmediafamily] a join [msdb].[dbo].[backupset] b on b.media_set_id = a.media_set_id<br />
where b.backup_start_date =<br />
(<br />
  select max( backup_start_date ) from [msdb].[dbo].[backupset]<br />
   where database_name = b.database_name and type = 'D'<br />
)<br />
and database_name = '&lt;database_name&gt;'<br />
)</p>
<p>-- print @bksource</p>
<p>restore database [&lt;Database_Name2&gt;] from disk = @bksource with replace, stats = 10,<br />
MOVE '&lt;Database_Name&gt;' TO 'i:\mssql\data\test\&lt;Database_Name2&gt;.MDF',<br />
MOVE '&lt;Database_Name&gt;_log' TO 'j:\mssql\xlog\test\&lt;Database_Name2&gt;_log.LDF'<br />
GO</p>
<p>Replace anything inside the &lt;&gt; with the proper names and set the correct drive letters.</p>
<div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/MichaelDeputy?a=NgpIcelPjDc:MicSjj8Urug:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/MichaelDeputy?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/MichaelDeputy?a=NgpIcelPjDc:MicSjj8Urug:V_sGLiPBpWU"><img src="http://feeds.feedburner.com/~ff/MichaelDeputy?i=NgpIcelPjDc:MicSjj8Urug:V_sGLiPBpWU" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/MichaelDeputy/~4/NgpIcelPjDc" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.deputyfamily.net/MichaelDeputy/archive/2010/08/restoring-last-full-backup/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://www.deputyfamily.net/MichaelDeputy/archive/2010/08/restoring-last-full-backup/</feedburner:origLink></item>
		<item>
		<title>DBCC Checkdb</title>
		<link>http://feedproxy.google.com/~r/MichaelDeputy/~3/p67MNvMecXk/</link>
		<comments>http://www.deputyfamily.net/MichaelDeputy/archive/2010/04/dbcc-checkdb/#comments</comments>
		<pubDate>Sun, 25 Apr 2010 21:29:51 +0000</pubDate>
		<dc:creator>MichaelDeputy</dc:creator>
				<category><![CDATA[MSSQL]]></category>
		<category><![CDATA[Database]]></category>
		<category><![CDATA[SQL Server]]></category>

		<guid isPermaLink="false">http://www.deputyfamily.net/MichaelDeputy/?p=268</guid>
		<description><![CDATA[Last weekend I attended SQL Saturday in Chicago. During one of the sessions there was a brief discussion about DBCC CHECKDB.  The long and short of it:  It is important, do them, it is not an option to skip this check.  It is right up there with Index maintenance and updating statistics.  But, no one [...]]]></description>
			<content:encoded><![CDATA[<p>Last weekend I attended SQL Saturday in Chicago.</p>
<div id="attachment_270" class="wp-caption alignright" style="width: 310px"><a href="http://www.scapgroup.us/images/thinking_man_ifx6.png"><img src="http://www.deputyfamily.net/MichaelDeputy/wp-content/uploads/2010/04/thinking_man_ifx6-300x206.png" class="size-medium wp-image-270" title="thinking_man_ifx6" alt="How do I get all my SQL server healthy?" width="300" height="206" /></a><p class="wp-caption-text">How do I get all my SQL server healthy?</p></div>
<p>During one of the sessions there was a brief discussion about DBCC CHECKDB.  The long and short of it:  It is important, do them, it is not an option to skip this check.  It is right up there with Index maintenance and updating statistics.  But, no one ever said that you had to run them on your production database.  I repeat, no one said you had to run them on your production database.  Here's a couple of thoughts.  First when you do your weekly backup/restore test, notice I didn't say 'if', run the DBCC CHECKDB against your restored copy.  If you have inconsistencies in your production database, it will also exist in an exact copy of you database.  But remember to fix it on your production database and not you copy that you will drop later.  Another option is if you use backup/restore to create a report server.  This is an excellent way to do the checks and verify your backups are good.  We have a couple of systems that we do this every night when the SQL backup is complete, we restore it the report server.  Proved the backups are good.  I then look for a time that Crystal Info is not pounding the report server and run the dbcc checks against that database copy.  I have it e-mail me if it finds any errors.  Kills two birds with one stone.  Now for the truth in my shop.  With over 120 instances and over 1600 databases, a weekly backup test and DBCC CHECKDB is just not practical.  So I use a hybrid approach.  The servers that refresh a report server daily are easy perfect candidates, our larger (high priority) databases get a restore to a test server and DBCC CHECKDB there, and the other databases get an occasional backup/restore test and DBCC CHECKDB run against the production database once per week during slow times.  So think outside the box.  Find a way to verify your database's consistancy.</p>
<p>Dep</p>
<div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/MichaelDeputy?a=p67MNvMecXk:8AEEmEnO0Ts:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/MichaelDeputy?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/MichaelDeputy?a=p67MNvMecXk:8AEEmEnO0Ts:V_sGLiPBpWU"><img src="http://feeds.feedburner.com/~ff/MichaelDeputy?i=p67MNvMecXk:8AEEmEnO0Ts:V_sGLiPBpWU" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/MichaelDeputy/~4/p67MNvMecXk" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.deputyfamily.net/MichaelDeputy/archive/2010/04/dbcc-checkdb/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://www.deputyfamily.net/MichaelDeputy/archive/2010/04/dbcc-checkdb/</feedburner:origLink></item>
		<item>
		<title>Blog Site Changes</title>
		<link>http://feedproxy.google.com/~r/MichaelDeputy/~3/52pkFS4xHK4/</link>
		<comments>http://www.deputyfamily.net/MichaelDeputy/archive/2010/03/blog-site-changes/#comments</comments>
		<pubDate>Fri, 19 Mar 2010 17:00:59 +0000</pubDate>
		<dc:creator>MichaelDeputy</dc:creator>
				<category><![CDATA[Introduction]]></category>
		<category><![CDATA[Twitter]]></category>
		<category><![CDATA[Useless Information]]></category>

		<guid isPermaLink="false">http://www.deputyfamily.net/MichaelDeputy/?p=260</guid>
		<description><![CDATA[On a whim a few days ago, I looked at my feedburner statistics.  I was shocked to learn that there are 20 people who have subscribed  to my feed.  So I thought I better spend some more time on my blog in order thank those people for their time and attention.  So I am planning [...]]]></description>
			<content:encoded><![CDATA[<p>On a whim a few days ago, I looked at my feedburner statistics.  I was shocked to learn that there are 20 people who have subscribed  to my feed.  So I thought I better spend some more time on my blog in order thank those people for their time and attention.  So I am planning to have fewer of these useless posts and concentrate on more meaty posts that might actually help someone out.</p>
<p>Secondly, I decided that I wanted to change my twitter handle and I thought about it for quite a while and thought blending my last name with my job as a SQL Server DBA.  So I morphed into SQLLawman.  I'm following suit and changed my blog to follow suit.</p>
<p>Finally, I found a new theme for my blog and I really like the simple nature, so I think I'll work from here to edit and add features as time goes by.</p>
<div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/MichaelDeputy?a=52pkFS4xHK4:4jDkfFEU3PI:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/MichaelDeputy?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/MichaelDeputy?a=52pkFS4xHK4:4jDkfFEU3PI:V_sGLiPBpWU"><img src="http://feeds.feedburner.com/~ff/MichaelDeputy?i=52pkFS4xHK4:4jDkfFEU3PI:V_sGLiPBpWU" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/MichaelDeputy/~4/52pkFS4xHK4" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.deputyfamily.net/MichaelDeputy/archive/2010/03/blog-site-changes/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://www.deputyfamily.net/MichaelDeputy/archive/2010/03/blog-site-changes/</feedburner:origLink></item>
		<item>
		<title>Who’s Winning the Olympics?</title>
		<link>http://feedproxy.google.com/~r/MichaelDeputy/~3/Svc2ZtTnxyU/</link>
		<comments>http://www.deputyfamily.net/MichaelDeputy/archive/2010/02/whos-winning-the-olympics/#comments</comments>
		<pubDate>Sun, 28 Feb 2010 19:55:25 +0000</pubDate>
		<dc:creator>MichaelDeputy</dc:creator>
				<category><![CDATA[Olympics]]></category>
		<category><![CDATA[Useless Information]]></category>

		<guid isPermaLink="false">http://www.deputyfamily.net/MichaelDeputy/?p=217</guid>
		<description><![CDATA[I love the Olympics.  I enjoy watching the competition, and occasionally I enjoy the behind the scenes, human interest story.  But one thing that I struggle with is: Who is winning?  Depending win where you look you can see who has the most medals, who has the most gold medals, etc.  So I am going [...]]]></description>
			<content:encoded><![CDATA[<p>I love the Olympics.  I enjoy watching the competition, and occasionally I enjoy the behind the scenes, human interest story.  But one thing that I struggle with is: Who is winning?  Depending win where you look you can see who has the most medals, who has the most gold medals, etc.  So I am going to throw my scoring into the mix.  Yes, it is probably as convoluted as the scoring in figure skating. (what is the difference between at <a href="http://en.wikipedia.org/wiki/Toe_loop_jump">toe loop</a> and a <a href="http://en.wikipedia.org/wiki/Lutz_jump">lutz</a> anyway?)  So here's my scoring:</p>
<ol>
<li>Every Gold is worth 3 points</li>
<li>Every Silver is worth 2 points</li>
<li>Every Bronze is worth 1 point</li>
</ol>
<p>Yep, more points for the winners.  But this is where my scoring becomes interesting.  I divide the number of points by the number of athletes.  I found the number of athletes from <a title="http://www.vancouver2010.com/" href="http://www.vancouver2010.com/">http://www.vancouver2010.com/</a>.  What I find cool about this is that figures out which country sent the best athletes.  That's my idea of who wins.  Since this my blog I get to make my own rules.  So without further ado, here's the current top 10: Final Standings Updated 2/28/10 2:55 pm EST</p>
<table border="5" cellspacing="0" cellpadding="2" width="429">
<tbody>
<tr>
<td width="35" align="center">Place</td>
<td width="89" align="center">
<p align="center">Country</p>
</td>
<td width="52" align="center">
<p align="center">Athletes</p>
</td>
<td width="46" align="center">
<p align="center">Gold</p>
</td>
<td width="47" align="center">
<p align="center">Silver</p>
</td>
<td width="52" align="center">
<p align="center">Bronze</p>
</td>
<td width="49" align="center">
<p align="center">Points</p>
</td>
<td width="49" align="center">
<p align="center">Points per Athlete</p>
</td>
</tr>
<tr>
<td width="35" align="center">1</td>
<td width="89" align="center">
<p align="left">Republic of Korea</p>
</td>
<td width="52" align="center">46</td>
<td width="46" align="center">6</td>
<td width="47" align="center">6</td>
<td width="52" align="center">2</td>
<td width="49" align="center">32</td>
<td width="49" align="center">.696</td>
</tr>
<tr>
<td width="35" align="center">2</td>
<td width="89" align="center">
<p align="left">Netherlands</p>
</td>
<td width="52" align="center">34</td>
<td width="46" align="center">4</td>
<td width="47" align="center">1</td>
<td width="52" align="center">3</td>
<td width="49" align="center">17</td>
<td width="49" align="center">.500</td>
</tr>
<tr>
<td width="35" align="center">3</td>
<td width="89" align="center">
<p align="left">Norway</p>
</td>
<td width="52" align="center">99</td>
<td width="46" align="center">9</td>
<td width="47" align="center">8</td>
<td width="52" align="center">6</td>
<td width="49" align="center">49</td>
<td width="49" align="center">.459</td>
</tr>
<tr>
<td width="35" align="center">
<p align="center">4</p>
</td>
<td width="89" align="center">
<p align="left">Germany</p>
</td>
<td width="52" align="center">153</td>
<td width="46" align="center">10</td>
<td width="47" align="center">13</td>
<td width="52" align="center">7</td>
<td width="49" align="center">63</td>
<td width="49" align="center">.412</td>
</tr>
<tr>
<td width="35" align="center">5</td>
<td width="89" align="center">
<p align="left">Austria</p>
</td>
<td width="52" align="center">81</td>
<td width="46" align="center">4</td>
<td width="47" align="center">6</td>
<td width="52" align="center">6</td>
<td width="49" align="center">30</td>
<td width="49" align="center">.370</td>
</tr>
<tr>
<td width="35" align="center">6</td>
<td width="89" align="center">
<p align="left">United States of America</p>
</td>
<td width="52" align="center">215</td>
<td width="46" align="center">9</td>
<td width="47" align="center">15</td>
<td width="52" align="center">13</td>
<td width="49" align="center">70</td>
<td width="49" align="center">.326</td>
</tr>
<tr>
<td width="35" align="center">7</td>
<td width="89" align="center">
<p align="left">Canada</p>
</td>
<td width="52" align="center">205</td>
<td width="46" align="center">14</td>
<td width="47" align="center">7</td>
<td width="52" align="center">5</td>
<td width="49" align="center">61</td>
<td width="49" align="center">.298</td>
</tr>
<tr>
<td width="35" align="center">8</td>
<td width="89" align="center">
<p align="left">Croatia</p>
</td>
<td width="52" align="center">18</td>
<td width="46" align="center">0</td>
<td width="47" align="center">2</td>
<td width="52" align="center">1</td>
<td width="49" align="center">5</td>
<td width="49" align="center">.278</td>
</tr>
<tr>
<td width="35" align="center">9</td>
<td width="89" align="center">
<p align="left">People's Republic of China</p>
</td>
<td width="52" align="center">90</td>
<td width="46" align="center">5</td>
<td width="47" align="center">2</td>
<td width="52" align="center">4</td>
<td width="49" align="center">23</td>
<td width="49" align="center">.256</td>
</tr>
<tr>
<td width="35" align="center">
<p align="center">10</p>
</td>
<td width="89" align="center">
<p align="left">Poland</p>
</td>
<td width="52" align="center">
<p align="center">50</p>
</td>
<td width="46" align="center">
<p align="center">1</p>
</td>
<td width="47" align="center">
<p align="center">3</p>
</td>
<td width="52" align="center">
<p align="center">2</p>
</td>
<td width="49" align="center">
<p align="center">11</p>
</td>
<td width="49" align="center">
<p align="center">.220</p>
</td>
</tr>
</tbody>
</table>
<div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/MichaelDeputy?a=Svc2ZtTnxyU:0g42bGdXoQ0:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/MichaelDeputy?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/MichaelDeputy?a=Svc2ZtTnxyU:0g42bGdXoQ0:V_sGLiPBpWU"><img src="http://feeds.feedburner.com/~ff/MichaelDeputy?i=Svc2ZtTnxyU:0g42bGdXoQ0:V_sGLiPBpWU" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/MichaelDeputy/~4/Svc2ZtTnxyU" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.deputyfamily.net/MichaelDeputy/archive/2010/02/whos-winning-the-olympics/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		<feedburner:origLink>http://www.deputyfamily.net/MichaelDeputy/archive/2010/02/whos-winning-the-olympics/</feedburner:origLink></item>
		<item>
		<title>Free Bacon at the PASS Summit</title>
		<link>http://feedproxy.google.com/~r/MichaelDeputy/~3/0TL2tewR2Zc/</link>
		<comments>http://www.deputyfamily.net/MichaelDeputy/archive/2009/09/free-bacon-at-the-pass-summit/#comments</comments>
		<pubDate>Fri, 25 Sep 2009 18:00:26 +0000</pubDate>
		<dc:creator>MichaelDeputy</dc:creator>
				<category><![CDATA[Virtualization Chapter]]></category>
		<category><![CDATA[PASS]]></category>

		<guid isPermaLink="false">http://www.deputyfamily.net/MichaelDeputy/?p=203</guid>
		<description><![CDATA[Yes I'm serious.  If you are going to the PASS Summit in Seattle there is an opportunity to get FREE BACON.  The SQL Virtualization Virtual PASS chapter is hosting a breakfast and game show on Tuesday November 3rd at 7:30 am and you are invited.  Do you have questions about virtualizing  SQL?  Do you have [...]]]></description>
			<content:encoded><![CDATA[<p>Yes I'm serious.  If you are going to the <a href="http://summit2009.sqlpass.org/" target="_blank">PASS Summit</a> in Seattle there is an opportunity to get FREE BACON.  The <a href="http://virtualization.sqlpass.org/" target="_blank">SQL Virtualization Virtual PASS chapter</a> is hosting a breakfast and game show on Tuesday November 3rd at 7:30 am and you are invited.  Do you have questions about virtualizing  SQL?  Do you have answers about virtualizing SQL?  Do you not care about virtualizing SQL and just want a good breakfast?  Come join us.  Experts from VMWare will be on hand to answer questions.  There will be fun, prizes, and food.  Now here is where it gets really cool.  We are looking for contestants.  If you are thinking about virtualization, actively engaged in virtualizations or already been there, done that, bought the T-shirt  you may qualify to be in the game show.  Very soon we will have a registration page that will give you the opportunity of a lifetime to play.  So what kind of game will this be?  Have you seen <a href="http://www.tv.com/wipeout/show/75217/summary.html">Wipe Out</a>?  A really fun game show about people embarrassing themselves on a muddy, messy, wet obstacle course with &laquo;Big Balls&raquo;?</p>
<p><a href="http://www.huffingtonpost.com/2008/08/08/2008-the-summer-without-a_n_117686.html"><img src="http://www.deputyfamily.net/MichaelDeputy/wp-content/uploads/2009/10/sWIPEOUTlarge.jpg" style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="s-WIPEOUT-large" border="0" alt="s-WIPEOUT-large" width="244" height="179" /></a></p>
<p>Well, this has absolutely nothing to do with that, but it will be fun and energetic all the same.  If you are going to the PASS Summit click <a href="http://www.sqlpass.org/Events/ctl/ViewEvent/mid/521.aspx?ID=247">here</a> for more information and to register for the event. If you want to ensure there is enough bacon for everyone, please register before the event.  Unfortunately you will not get to opportunity to meet me this  year at the summit, but I'm really hoping for next year.  So<a href="http://www.sqlpass.org/Events/ctl/ViewEvent/mid/521.aspx?ID=247"> register</a>, get some free stuff and bacon.</p>
<div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/MichaelDeputy?a=0TL2tewR2Zc:wF_oCziPZN0:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/MichaelDeputy?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/MichaelDeputy?a=0TL2tewR2Zc:wF_oCziPZN0:V_sGLiPBpWU"><img src="http://feeds.feedburner.com/~ff/MichaelDeputy?i=0TL2tewR2Zc:wF_oCziPZN0:V_sGLiPBpWU" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/MichaelDeputy/~4/0TL2tewR2Zc" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.deputyfamily.net/MichaelDeputy/archive/2009/09/free-bacon-at-the-pass-summit/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://www.deputyfamily.net/MichaelDeputy/archive/2009/09/free-bacon-at-the-pass-summit/</feedburner:origLink></item>
		<item>
		<title>Find locked SQL accounts on SQL 2005</title>
		<link>http://feedproxy.google.com/~r/MichaelDeputy/~3/Og9TAZjBSkg/</link>
		<comments>http://www.deputyfamily.net/MichaelDeputy/archive/2009/09/find-locked-sql-accounts-on-sql-2005/#comments</comments>
		<pubDate>Wed, 16 Sep 2009 15:38:23 +0000</pubDate>
		<dc:creator>MichaelDeputy</dc:creator>
				<category><![CDATA[MSSQL]]></category>
		<category><![CDATA[Database]]></category>
		<category><![CDATA[SQL Server]]></category>
		<category><![CDATA[t-sql]]></category>

		<guid isPermaLink="false">http://www.deputyfamily.net/MichaelDeputy/?p=194</guid>
		<description><![CDATA[We are in the process of upgrading a Microsoft product that just hasn't gotten around to integrating with AD and uses SQL accounts.  It also has a really bad habit of locking SQL accounts if your AD policy for failed login attempts is set low.  So I got tired of searching through SSMS to unlock [...]]]></description>
			<content:encoded><![CDATA[<p>We are in the process of upgrading a Microsoft product that just hasn't gotten around to integrating with AD and uses SQL accounts.  It also has a really bad habit of locking SQL accounts if your AD policy for failed login attempts is set low.  So I got tired of searching through SSMS to unlock accounts, so I wrote a quick script to list the locked accounts and the command to unlock it.  I didn't go as far as to auto-unlock the locked accounts but that would be a simple edit.  Here's the script.</p>
<p>Declare @UserID varchar(25), @status nvarchar(5), @Command varchar(255), @command1 varchar(255)<br />
Declare Account_cursor Cursor<br />
for select name from sys.syslogins where name not like '&lt;DOMAIN&gt;\%'<br />
open Account_cursor<br />
FETCH NEXT FROM Account_cursor<br />
INTO @UserID<br />
WHILE @@FETCH_STATUS = 0<br />
BEGIN<br />
select @status= convert(nvarchar,(loginproperty(@userID,N'IsLocked')))<br />
if @status = '1'<br />
BEGIN<br />
print '-- ' + @userID + ' is locked'<br />
select @command = 'ALTER LOGIN [' + @userID + '] WITH DEFAULT_DATABASE=[master], DEFAULT_LANGUAGE=[us_english], CHECK_EXPIRATION=OFF, CHECK_POLICY=OFF, NO CREDENTIAL'<br />
select @command1 = 'ALTER LOGIN [' + @userID + '] WITH DEFAULT_DATABASE=[master], DEFAULT_LANGUAGE=[us_english], CHECK_EXPIRATION=OFF, CHECK_POLICY=ON, NO CREDENTIAL'<br />
print @command<br />
print @command1<br />
-- exec (@command)<br />
-- exec (@command1)<br />
END<br />
fetch next from Account_Cursor into @userID<br />
END<br />
Close Account_cursor<br />
Deallocate Account_cursor</p>
<p>Thank you <a href="http://twitter.com/unclebiguns">@</a><span><span><a href="http://twitter.com/unclebiguns">unclebiguns</a> for pointing me toward the function that makes this all possible. </span></span></p>
<p>I am guessing that this is not the easiest or most efficient way to do this, so if anyone would like to educate me on a better way, I am very open to learning your techniques.</p>
<div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/MichaelDeputy?a=Og9TAZjBSkg:l-ja6gHBR_U:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/MichaelDeputy?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/MichaelDeputy?a=Og9TAZjBSkg:l-ja6gHBR_U:V_sGLiPBpWU"><img src="http://feeds.feedburner.com/~ff/MichaelDeputy?i=Og9TAZjBSkg:l-ja6gHBR_U:V_sGLiPBpWU" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/MichaelDeputy/~4/Og9TAZjBSkg" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.deputyfamily.net/MichaelDeputy/archive/2009/09/find-locked-sql-accounts-on-sql-2005/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://www.deputyfamily.net/MichaelDeputy/archive/2009/09/find-locked-sql-accounts-on-sql-2005/</feedburner:origLink></item>
		<item>
		<title>Find all Triggers</title>
		<link>http://feedproxy.google.com/~r/MichaelDeputy/~3/AgJsVkES8gM/</link>
		<comments>http://www.deputyfamily.net/MichaelDeputy/archive/2009/08/find-all-triggers/#comments</comments>
		<pubDate>Tue, 18 Aug 2009 12:55:41 +0000</pubDate>
		<dc:creator>MichaelDeputy</dc:creator>
				<category><![CDATA[MSSQL]]></category>
		<category><![CDATA[Database]]></category>
		<category><![CDATA[SQL Server]]></category>
		<category><![CDATA[t-sql]]></category>

		<guid isPermaLink="false">http://www.deputyfamily.net/MichaelDeputy/?p=173</guid>
		<description><![CDATA[I was asked to find all tables in a database that had a DML trigger so a developer could ensure that all the old functionality was available in the new database.  So once I built my query to give me the information, I thought I'd save it here for future use. select a.name as 'Trigger', [...]]]></description>
			<content:encoded><![CDATA[<p>I was asked to find all tables in a database that had a DML trigger so a developer could ensure that all the old functionality was available in the new database.  So once I built my query to give me the information, I thought I'd save it here for future use.</p>
<p>select a.name as 'Trigger', b.name as 'Table'<br />
from sysobjects a<br />
join sysobjects b<br />
on a.parent_obj=b.id<br />
where a.xtype = 'TR'</p>
<p>This gave me a nice little result set of each trigger and what table it was associated.  Maybe I won't have to re-invent the wheel the next time they ask.</p>
<div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/MichaelDeputy?a=AgJsVkES8gM:-xlWuuK0Fvw:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/MichaelDeputy?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/MichaelDeputy?a=AgJsVkES8gM:-xlWuuK0Fvw:V_sGLiPBpWU"><img src="http://feeds.feedburner.com/~ff/MichaelDeputy?i=AgJsVkES8gM:-xlWuuK0Fvw:V_sGLiPBpWU" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/MichaelDeputy/~4/AgJsVkES8gM" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.deputyfamily.net/MichaelDeputy/archive/2009/08/find-all-triggers/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		<feedburner:origLink>http://www.deputyfamily.net/MichaelDeputy/archive/2009/08/find-all-triggers/</feedburner:origLink></item>
		<item>
		<title>SKU is Invalid when installing 2nd node in SQL 2008</title>
		<link>http://feedproxy.google.com/~r/MichaelDeputy/~3/0gpoI9eTgyo/</link>
		<comments>http://www.deputyfamily.net/MichaelDeputy/archive/2009/07/sku-is-invalid-when-installing-2nd-node-in-sql-2008/#comments</comments>
		<pubDate>Thu, 16 Jul 2009 20:54:09 +0000</pubDate>
		<dc:creator>MichaelDeputy</dc:creator>
				<category><![CDATA[MSSQL]]></category>
		<category><![CDATA[SQL Server]]></category>

		<guid isPermaLink="false">http://www.deputyfamily.net/MichaelDeputy/?p=171</guid>
		<description><![CDATA[I was installing SQL Server 2008 on a Windows 2008 cluster the other day and I received and error:  'The current SKU is Invalid'.  So I went looking for the resolution.  I came across  a blog post by Vittorio Pavesi that pointed me to the answer.  I did not take the course of copying the [...]]]></description>
			<content:encoded><![CDATA[<p>I was installing SQL Server 2008 on a Windows 2008 cluster the other day and I received and error:  'The current SKU is Invalid'.  So I went looking for the resolution.  I came across  a blog post by <a href="http://vittoriop77.blogspot.com/2009/02/sql-2008-cluster-current-sku-is-invalid.html">Vittorio Pavesi</a> that pointed me to the answer.  I did not take the course of copying the install files to the local server.  I was installing from a network share, so I simply moved the file  DefaultSetup.ini to a new location and started the 'Add node to a SQL Server failover cluster'  again and entered the key included on the DefaultSetup.ini manually.  The rest of the install went without issue.</p>
<div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/MichaelDeputy?a=0gpoI9eTgyo:efC6kzG3FKY:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/MichaelDeputy?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/MichaelDeputy?a=0gpoI9eTgyo:efC6kzG3FKY:V_sGLiPBpWU"><img src="http://feeds.feedburner.com/~ff/MichaelDeputy?i=0gpoI9eTgyo:efC6kzG3FKY:V_sGLiPBpWU" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/MichaelDeputy/~4/0gpoI9eTgyo" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.deputyfamily.net/MichaelDeputy/archive/2009/07/sku-is-invalid-when-installing-2nd-node-in-sql-2008/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		<feedburner:origLink>http://www.deputyfamily.net/MichaelDeputy/archive/2009/07/sku-is-invalid-when-installing-2nd-node-in-sql-2008/</feedburner:origLink></item>
		<item>
		<title>Today's PSA</title>
		<link>http://feedproxy.google.com/~r/MichaelDeputy/~3/wbuzOOhQhL4/</link>
		<comments>http://www.deputyfamily.net/MichaelDeputy/archive/2009/07/todays-psa/#comments</comments>
		<pubDate>Sun, 12 Jul 2009 00:22:59 +0000</pubDate>
		<dc:creator>MichaelDeputy</dc:creator>
				<category><![CDATA[Family Life]]></category>
		<category><![CDATA[PSA]]></category>

		<guid isPermaLink="false">http://www.deputyfamily.net/MichaelDeputy/?p=168</guid>
		<description><![CDATA[According to the American Red Cross here are 10 facts about the need for blood donation. 1. Every two seconds someone in the U.S. needs blood 2. More than 38,000 blood donations are needed every day 3. One out of every 10 people admitted in a hospital needs blood 4. Total blood transfusions in a [...]]]></description>
			<content:encoded><![CDATA[<p>According to the<a href="http://www.givelife2.org/sponsor/quickfacts.asp"> American Red Cross</a> here are 10 facts about the need for blood donation.</p>
<table border="0" cellspacing="0" cellpadding="5" width="100%">
<tbody>
<tr>
<td width="25" align="right" valign="top">1.</td>
<td valign="top">Every two seconds someone in the U.S. needs blood</td>
</tr>
<tr>
<td width="25" align="right" valign="top">2.</td>
<td valign="top">More than 38,000 blood donations are needed every day</td>
</tr>
<tr>
<td width="25" align="right" valign="top">3.</td>
<td valign="top">One out of every 10 people admitted in a hospital needs blood</td>
</tr>
<tr>
<td width="25" align="right" valign="top">4.</td>
<td valign="top">Total blood transfusions in a given year: 14 million (2001)</td>
</tr>
<tr>
<td width="25" align="right" valign="top">5.</td>
<td valign="top">The average red blood cell transfusion is approximately 3 pints</td>
</tr>
<tr>
<td width="25" align="right" valign="top">6.</td>
<td valign="top">The blood type most often requested by hospitals is Type O</td>
</tr>
<tr>
<td width="25" align="right" valign="top">7.</td>
<td valign="top">The blood used in an emergency is already on the shelves before the event occurs</td>
</tr>
<tr>
<td width="25" align="right" valign="top">8.</td>
<td valign="top">Sickle cell disease affects more than 80,000 people in the U.S., 98% of whom are African American. Sickle cell patients can require frequent blood transfusions throughout their lives</td>
</tr>
<tr>
<td width="25" align="right" valign="top">9.</td>
<td valign="top">More than 1 million new people are diagnosed with cancer each year. Many of them will need blood, sometimes daily, during their chemotherapy treatment.</td>
</tr>
<tr>
<td width="25" align="right" valign="top">10.</td>
<td valign="top">A single car accident victim can require as many as 100 units of blood.</td>
</tr>
</tbody>
</table>
<p>Please consider donating.  Whole blood can be donated every 56 days.</p>
<div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/MichaelDeputy?a=wbuzOOhQhL4:rNTdVHKaxmo:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/MichaelDeputy?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/MichaelDeputy?a=wbuzOOhQhL4:rNTdVHKaxmo:V_sGLiPBpWU"><img src="http://feeds.feedburner.com/~ff/MichaelDeputy?i=wbuzOOhQhL4:rNTdVHKaxmo:V_sGLiPBpWU" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/MichaelDeputy/~4/wbuzOOhQhL4" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.deputyfamily.net/MichaelDeputy/archive/2009/07/todays-psa/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://www.deputyfamily.net/MichaelDeputy/archive/2009/07/todays-psa/</feedburner:origLink></item>
		<item>
		<title>Stored Procedure with Execute as</title>
		<link>http://feedproxy.google.com/~r/MichaelDeputy/~3/giuMnhsqJ20/</link>
		<comments>http://www.deputyfamily.net/MichaelDeputy/archive/2009/06/stored-procedure-with-execute-as/#comments</comments>
		<pubDate>Tue, 02 Jun 2009 13:56:54 +0000</pubDate>
		<dc:creator>MichaelDeputy</dc:creator>
				<category><![CDATA[MSSQL]]></category>
		<category><![CDATA[Database]]></category>
		<category><![CDATA[SQL Server]]></category>
		<category><![CDATA[t-sql]]></category>

		<guid isPermaLink="false">http://www.deputyfamily.net/MichaelDeputy/?p=166</guid>
		<description><![CDATA[We have a database that holds information that is fairly personal, so much that the application team that supports it may only have read access to the database.  There came a need to occasionally lock all the administrators out of the system for updates.  These updates will occur every few months.  So I created a [...]]]></description>
			<content:encoded><![CDATA[<p>We have a database that holds information that is fairly personal, so much that the application team that supports it may only have read access to the database.  There came a need to occasionally lock all the administrators out of the system for updates.  These updates will occur every few months.  So I created a SQL user and gave that user select and update rights to the necessary table.  Then I created a couple of stored procs, one to disable the logins and one to enable the logins.</p>
<p>CREATE PROCEDURE [dbo].[LockOutAdministrators]<br />
WITH EXECUTE AS 'EXECUTIONER'<br />
AS<br />
BEGIN<br />
BLAH, BLAH, BLAH<br />
END</p>
<p>I then granted execute to the stored procedures to the application group.  So the application team can only update the table via the stored procedure that does only what it needs to do.  They are happy they have an easy way to do this without me becoming the bottle neck.  If this was a more sensitive system, I'd probably add some auditing, but it is not necessary at this time.</p>
<div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/MichaelDeputy?a=giuMnhsqJ20:AIjjbx2MNHg:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/MichaelDeputy?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/MichaelDeputy?a=giuMnhsqJ20:AIjjbx2MNHg:V_sGLiPBpWU"><img src="http://feeds.feedburner.com/~ff/MichaelDeputy?i=giuMnhsqJ20:AIjjbx2MNHg:V_sGLiPBpWU" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/MichaelDeputy/~4/giuMnhsqJ20" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.deputyfamily.net/MichaelDeputy/archive/2009/06/stored-procedure-with-execute-as/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://www.deputyfamily.net/MichaelDeputy/archive/2009/06/stored-procedure-with-execute-as/</feedburner:origLink></item>
	</channel>
</rss>
