<?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/" version="2.0">

<channel>
	<title>Richard Douglas - SQL Server Professional</title>
	
	<link>http://sql.richarddouglas.co.uk</link>
	<description>Real world SQL advice and tips</description>
	<lastBuildDate>Wed, 01 Sep 2010 09:39:25 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0</generator>
		<atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="self" type="application/rss+xml" href="http://feeds.feedburner.com/co/LJKyU" /><feedburner:info xmlns:feedburner="http://rssnamespace.org/feedburner/ext/1.0" uri="co/ljkyu" /><atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="hub" href="http://pubsubhubbub.appspot.com/" /><item>
		<title>SQL Workshops</title>
		<link>http://sql.richarddouglas.co.uk/archive/2010/09/sql-workshops.html</link>
		<comments>http://sql.richarddouglas.co.uk/archive/2010/09/sql-workshops.html#comments</comments>
		<pubDate>Wed, 01 Sep 2010 09:37:47 +0000</pubDate>
		<dc:creator>Richard Douglas</dc:creator>
				<category><![CDATA[Performance Tuning]]></category>

		<guid isPermaLink="false">http://sql.richarddouglas.co.uk/?p=528</guid>
		<description><![CDATA[<p>If you have been to any of the SQLBits events many of you will have no doubt made a conscious effort to go to the sessions by Ramesh Meyyappan. Ramesh is absolutely awesome at performance tuning, you can see some of his previous presentations at the SQLBits site here, but did you know that he has [...]]]></description>
			<content:encoded><![CDATA[<p>If you have been to any of the SQLBits events many of you will have no doubt made a conscious effort to go to the sessions by Ramesh Meyyappan. Ramesh is absolutely awesome at performance tuning, you can see some of his previous presentations at the SQLBits site <a href="http://www.sqlbits.com/Speakers/R_Meyyappan/Default.aspx" target="_blank">here</a>, but did you know that he has also posted some fantastic free webcasts at <a href="http://www.sqlworkshops.com/webcast" target="_blank">http://www.sqlworkshops.com/webcast</a>?</p>
<p>I watched most of these a few months ago and wow, this is some serious stuff. I really fancied attending one of the courses as it truly is a level 400 course, take a look at the recommended reading list:</p>
<blockquote><p>My Book recommendation for developers:</p>
<p>I recommend reading Microsoft SQL Server 2008 series from Itzik Ben-Gan. He has contributed greatly to the SQL Server<br />
community by writing these technical books.</p>
<p>· Microsoft SQL Server 2008 T-SQL Fundamentals from Microsoft Press</p>
<p>· Inside Microsoft SQL Server 2008: T-SQL Querying from Microsoft Press</p>
<p>· Inside Microsoft SQL Server 2008: T-SQL Programming from Microsoft Press</p>
<p>Try to read the SQL Server 2008 books, even if you are not using SQL Server 2008 yet for 2 reasons, SQL Server 2005<br />
features are a subset SQL Server 2008, eventually you will use SQL Server 2008.</p>
<p>· Inside Microsoft SQL Server 2005: T-SQL Querying from Microsoft Press</p>
<p>· Inside Microsoft SQL Server 2005: T-SQL Programming from Microsoft Press</p>
<p>My book recommendation for administrators and developers:</p>
<p>I recommend developers to read above T-SQL books before they venture in to the below books. As a developer you have<br />
some responsibility to understand SQL Server architecture.</p>
<p>· Microsoft SQL Server 2008 Internals from Microsoft Press</p>
<p>· SQL Server 2005 Practical Troubleshooting: The Database Engine by Ken Henderson</p>
<p>· Inside Microsoft SQL Server 2005: Query Tuning and Optimization from Microsoft Press</p>
<p>· Inside Microsoft SQL Server(TM) 2005: The Storage Engine from Microsoft Press</p>
<p>· The Guru&#8217;s Guide to SQL Server Architecture and Internals by Ken Henderson</p>
<p>I have not read recent books, so I have no suggestion on them, may be you can share some of your opinions. I remember<br />
reading the &#8216;The Guru&#8217;s Guide to SQL Server Architecture and Internals by Ken Henderson&#8217; long long time ago, read<br />
chapter 10 again, I don&#8217;t remember the rest of the book much anymore, but chapter 10 is a must read.</p>
<p>Like I mentioned all books, like software having bugs, have mistakes, larger, smaller, cosmetic, technical, try to practice<br />
what you learn so you don&#8217;t learn something wrong. Keep away from undocumented stuff.</p>
<p>Read this blog from top to bottom, read twice if necessary: <a href="http://r20.rs6.net/tn.jsp?et=1103089762457&amp;s=625&amp;e=001GnndKSyRvDcM7dXJf9G0SUp5JOIUaJNfplwFt2-Ur6jpqCGQaTxtxy5xipjcbvkZr6KEtAZyY_DaMRrA6MB571PuL9MmCSkljh-oEdIEkuKqzyBlupIZcQ==">http://blogs.msdn.com/craigfr</a>, Craig Freedman blog is a<br />
chapter in &#8216;Inside Microsoft SQL Server 2005: Query Tuning and Optimization&#8217;, but I like the blog better, not just because<br />
it is free, it is alive, well was not for nearly 6 months, but is back. You know what I think, you need to keep sending Craig<br />
questions and comments, If not the number of blog entries will decrease over time.</p></blockquote>
<img src="http://feeds.feedburner.com/~r/co/LJKyU/~4/aK6N48IZiO8" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://sql.richarddouglas.co.uk/archive/2010/09/sql-workshops.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>SQL Patch Updates</title>
		<link>http://sql.richarddouglas.co.uk/archive/2010/08/sql-patch-updates.html</link>
		<comments>http://sql.richarddouglas.co.uk/archive/2010/08/sql-patch-updates.html#comments</comments>
		<pubDate>Tue, 31 Aug 2010 11:29:47 +0000</pubDate>
		<dc:creator>Richard Douglas</dc:creator>
				<category><![CDATA[Server Admin]]></category>

		<guid isPermaLink="false">http://sql.richarddouglas.co.uk/?p=524</guid>
		<description><![CDATA[<p>The following KB articles/patches for SQL Server have been released over the last few days:</p>
<p>SQL Sever 2005</p>

You have to reinstall some drivers when you install SQL Server 2005
FIX: A Deadlock occurs when two transactions try to perform a DML operation on a table that contains a TABLOCK locking hint or an XLOCK locking hint
Cumulative Update 2 [...]]]></description>
			<content:encoded><![CDATA[<p>The following KB articles/patches for SQL Server have been released over the last few days:</p>
<p><strong>SQL Sever 2005</strong></p>
<ul>
<li><a href="http://support.microsoft.com/kb/2008303/es" target="_blank">You have to reinstall some drivers when you install SQL Server 2005</a></li>
<li><a href="http://support.microsoft.com/kb/983516" target="_blank">FIX: A Deadlock occurs when two transactions try to perform a DML operation on a table that contains a TABLOCK locking hint or an XLOCK locking hint</a></li>
<li><a href="http://support.microsoft.com/kb/2289547" target="_blank">Cumulative Update 2 for SQL Server Compact 3.5 Service Pack 2</a></li>
<li><a href="http://support.microsoft.com/kb/2300599" target="_blank">FIX: Heap corruption occurs when you use SQL Server Compact 3.5 Service Pack 2</a></li>
</ul>
<p><strong> </strong></p>
<p><strong>SQL Server 2008</strong></p>
<ul>
<li><a href="http://support.microsoft.com/kb/2216504" target="_blank">General overhead performance differences when you view reports in SharePoint integrated mode versus in SharePoint native mode</a></li>
<li><a href="http://support.microsoft.com/kb/2020443" target="_blank">How to upgrade an expired installation of SQL Server 2008 Evaluation Edition to a retail version of SQL Server 2008</a></li>
<li><a href="http://support.microsoft.com/kb/2216485" target="_blank">FIX: Resource Monitor enters a non-yielding condition on a server that is running SQL Server 2008</a></li>
<li><a href="http://support.microsoft.com/kb/2292725" target="_blank">FIX: You experience decreased performance when you run an MDX query in SQL Server 2008 SP1 that has cumulative update 5 or a later version of the update package installed</a></li>
<li><a href="http://support.microsoft.com/kb/2280126" target="_blank">SQL Server 2008 full-text query may return false positives using number with more than 9 digits as search predicate condition</a></li>
<li><a href="http://support.microsoft.com/kb/2270849" target="_blank">Error 0x80040e97 can occur when indexing large document with integrated full-text search</a></li>
</ul>
<p> </p>
<p><strong>SQL Server 2008 R2</strong></p>
<ul>
<li><a href="http://support.microsoft.com/kb/2142496/" target="_blank">FIX: A SQL Server 2008 R2 Integration Services package does not run in SQL Server Business Intelligence Development Studio when you use a shared SQL configuration table</a></li>
</ul>
<img src="http://feeds.feedburner.com/~r/co/LJKyU/~4/ziHH9P1zZTs" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://sql.richarddouglas.co.uk/archive/2010/08/sql-patch-updates.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Recovering TempDB</title>
		<link>http://sql.richarddouglas.co.uk/archive/2010/08/recovering-tempdb.html</link>
		<comments>http://sql.richarddouglas.co.uk/archive/2010/08/recovering-tempdb.html#comments</comments>
		<pubDate>Fri, 27 Aug 2010 15:01:41 +0000</pubDate>
		<dc:creator>Richard Douglas</dc:creator>
				<category><![CDATA[DR]]></category>
		<category><![CDATA[Database Engine]]></category>
		<category><![CDATA[Server Admin]]></category>
		<category><![CDATA[TempDB]]></category>

		<guid isPermaLink="false">http://sql.richarddouglas.co.uk/?p=517</guid>
		<description><![CDATA[<p>In a previous post “Moving TempDB” I provided step by step instructions on how you can move your TempDB database with an emphasis on reducing disk IO contention. If you have read this post you will notice that I did not change the path for the TempDB database files from the USB stick back to their [...]]]></description>
			<content:encoded><![CDATA[<p>In a previous post “<a href="http://sql.richarddouglas.co.uk/archive/2010/08/moving-tempdb.html" target="_blank">Moving TempDB</a>” I provided step by step instructions on how you can move your TempDB database with an emphasis on reducing disk IO contention. If you have read this post you will notice that I did not change the path for the TempDB database files from the USB stick back to their default location, the reason for this is that I want to show you how you can recover SQL Server when TempDB is not available.</p>
<p>After starting up my machine this morning the instance tried to start up and not surprisingly failed, I have added a subsection of the SQL Log which provides the clues as to why the instance did not start:</p>
<blockquote><p>2010-08-27 08:45:08.89 Server      Dedicated administrator connection support was not started because it is disabled on this edition of SQL Server. If you want to use a dedicated administrator connection, restart SQL Server using the trace flag 7806. This is an informational message only. No user action is required.<br />
2010-08-27 08:45:08.97 spid10s     Error: 5123, Severity: 16, State: 1.<br />
2010-08-27 08:45:08.97 spid10s     CREATE FILE encountered operating system error 3(failed to retrieve text for this error. Reason: 15100) while attempting to open or create the physical file &#8216;J:\SQLTest\tempdb.mdf&#8217;.<br />
2010-08-27 08:45:09.15 spid10s     Error: 17204, Severity: 16, State: 1.<br />
2010-08-27 08:45:09.15 spid10s     FCB::Open failed: Could not open file J:\SQLTest\tempdb.mdf for file number 1.  OS error: 3(failed to retrieve text for this error. Reason: 15105).<br />
2010-08-27 08:45:09.17 spid10s     Error: 5120, Severity: 16, State: 101.<br />
2010-08-27 08:45:09.17 spid10s     Unable to open the physical file &#8220;J:\SQLTest\tempdb.mdf&#8221;. Operating system error 3: &#8220;3(failed to retrieve text for this error. Reason: 15105)&#8221;.</p></blockquote>
<p>After looking at the data in the log file you can clearly see the error is that it can not find the TempDB data file. In my case this was because I did not have the USB stick plugged in, but let’s use our imagination and pretend that this drive is actually a single physical disk that has failed to come back online after some kind of maintenance.</p>
<p>The first step is pretty obvious we need to start the instance up, however in reality this could be quite tricky as one of the things a SQL instance does when it starts up is perform a recovery of each database – including TempDB. Luckily the trace flag 3608 allows you to bypass this for every database baring the master database. It is not recommended to use this as a standard startup parameter, every time you start your instance you will want to ensure that each database is transactionally consistent. You will also need to add the /f parameter this will allow you to start up the instance in minimal configuration mode.</p>
<p>To start the instance again you should open up the command prompt (running as an administrator) and run the NET START command. In my environment the service I wanted to start was MSSQL$MAPS. The full command needed to run from the command prompt is shown below:</p>
<pre style="width: 99%; height: 1px;">NET START MSSQL$MAPS /f /T3608</pre>
<p>You should then see that the instance has been started successfully. Similar to the image below:</p>
<p><a href="http://sql.richarddouglas.co.uk/wp-content/uploads/2010/08/NETSTARTMAPS.png"><img style="display: inline; border: 0px;" title="NET START MAPS" src="http://sql.richarddouglas.co.uk/wp-content/uploads/2010/08/NETSTARTMAPS_thumb.png" border="0" alt="NET START MAPS" width="657" height="84" /></a></p>
<p>At this point we break out the old trusty SQLCMD utility which you can call from the same command prompt session. The command you will need is:</p>
<p>SQLCMD –S <em>Machine\Instance</em></p>
<p>At this point you are connected to the instance and can run the ALTER DATABASE statement as we did in “<a href="http://sql.richarddouglas.co.uk/archive/2010/08/moving-tempdb.html" target="_blank">Moving TempDB</a>”, I’ve included below the code I used to bring my TempDB database back to it’s default settings.</p>
<pre>ALTER DATABASE tempdb MODIFY FILE (NAME = 'tempdev',  FILENAME = 'C:\Program Files\Microsoft SQL Server\MSSQL10_50.MAPS\MSSQL\DATA\tempdb.mdf');
ALTER DATABASE tempdb MODIFY FILE (NAME = 'templog',  FILENAME = 'C:\Program Files\Microsoft SQL Server\MSSQL10_50.MAPS\MSSQL\DATA\tempdb.ldf');</pre>
<p>To execute a batch of commands in sqlcmd you must use the GO command. At this point you will receive confirmation that the command has completed successfully and you will be informed that the new path will be used the next time the database is started. Exit out of the SQLCMD session and restart the SQL instance.</p>
<p>Once you have restarted the service you will be able to log in to the instance using Management Studio, users will fall at your feet, managers will give you promotions, pay rises and anything that your heart desires.  Either that or someone will walk up to you and say “why did that take so long?”</p>
<img src="http://feeds.feedburner.com/~r/co/LJKyU/~4/x4crkRuG2I8" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://sql.richarddouglas.co.uk/archive/2010/08/recovering-tempdb.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Weekly SQL Blog round up WC 20100822</title>
		<link>http://sql.richarddouglas.co.uk/archive/2010/08/weekly-sql-blog-round-up-wc-20100822.html</link>
		<comments>http://sql.richarddouglas.co.uk/archive/2010/08/weekly-sql-blog-round-up-wc-20100822.html#comments</comments>
		<pubDate>Fri, 27 Aug 2010 12:30:11 +0000</pubDate>
		<dc:creator>Richard Douglas</dc:creator>
				<category><![CDATA[Ad-hoc]]></category>

		<guid isPermaLink="false">http://sql.richarddouglas.co.uk/?p=502</guid>
		<description><![CDATA[<p>It’s been a busy week again this week in both my professional and personal life, so not much time for reading community content. However I have noticed an outstandingly funny hash tag on Twitter #inappropriatePASSSessions, possibly my favourite so far is from Bill Fellows (Blog&#124;Twitter)</p>
<p></p>
<p>I would like to point out that no developers or managers were [...]]]></description>
			<content:encoded><![CDATA[<p>It’s been a busy week again this week in both my professional and personal life, so not much time for reading community content. However I have noticed an outstandingly funny hash tag on Twitter <a href="http://search.twitter.com/search?q=%23inappropriatePASSSessions" target="_blank">#inappropriatePASSSessions</a>, possibly my favourite so far is from Bill Fellows (<a href="http://billfellows.blogspot.com/" target="_blank">Blog</a>|<a href="http://www.twitter.com/billinkc" target="_blank">Twitter</a>)</p>
<p><a href="http://sql.richarddouglas.co.uk/wp-content/uploads/2010/08/BillinkcTweet.png"><img style="display: inline; border: 0px;" title="BillinkcTweet" src="http://sql.richarddouglas.co.uk/wp-content/uploads/2010/08/BillinkcTweet_thumb.png" border="0" alt="BillinkcTweet" width="303" height="106" /></a></p>
<p>I would like to point out that no developers or managers were harmed during the composition of this blog post.</p>
<p>If you fancy starting your own blog Simon Sabin (<a href="http://sqlblogcasts.com/blogs/simons" target="_blank">Blog</a>|<a href="http://twitter.com/simon_sabin" target="_blank">Twitter</a>) has written an entry on the tools he uses when blogging:<br />
<a href="http://sqlblogcasts.com/blogs/simons/archive/2010/08/24/blogging-how-do-you-do-it.aspx" target="_blank">Blogging – how do you do it?</a> <br />
Thanks to Simon I now know about the Windows 7 Snipping tool (which I used to take the tweet from TweetDeck above).</p>
<p>Once you have been blogging for a while, you might fancy trying your hand at presenting, Microsoft’s Andrew Fryer (<a href="http://blogs.technet.com/b/andrew/" target="_blank">Blog</a>|<a href="http://twitter.com/DeepFat" target="_blank">Twitter</a>) has written a blog entry on how Windows 7 can help make things easier:<br />
<a href="http://blogs.technet.com/b/andrew/archive/2010/08/27/windows-7-the-presenter-s-friend.aspx" target="_blank">Windows 7 the Presenter’s friend</a></p>
<p>Aaron Bertrand (<a href="http://sqlblog.com/blogs/aaron_bertrand/default.aspx" target="_blank">Blog</a>|<a href="http://twitter.com/aaronbertrand" target="_blank">Twitter</a>) has written a great blog entry on his findings of Red Gate’s new Storage Compress 5.0 product:<br />
<a href="http://sqlblog.com/blogs/aaron_bertrand/archive/2010/08/26/compression.aspx" target="_blank">First Look : Red Gate SQL Storage Compress 5.0</a></p>
<p>On SQLServerCentral.com you can find an interview with this years winner of Red Gate’s Exceptional DBA winner Tracy Hamlin (<a href="http://www.twitter.com/tracyhhamlin">Twitter</a>):<br />
<a href="http://www.sqlservercentral.com/articles/Exceptional+DBA/70965/" target="_blank">Tracy Hamlin, Exceptional DBA of 2010, on what it means to go the extra mile</a></p>
<p><a href="http://sqlserverpedia.com/" target="_blank">SQLServerPedia</a> syndicated blogger Michael J Swart (<a href="http://michaeljswart.com/" target="_blank">Blog</a>|<a href="http://twitter.com/MJSwart" target="_blank">Twitter</a>) has written about his SQL peeves in the post: <a href="http://michaeljswart.com/?p=823" target="_blank">Ten Things I Hate to See in T-SQL</a></p>
<img src="http://feeds.feedburner.com/~r/co/LJKyU/~4/qSEAQP8gZIM" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://sql.richarddouglas.co.uk/archive/2010/08/weekly-sql-blog-round-up-wc-20100822.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Moving TempDB</title>
		<link>http://sql.richarddouglas.co.uk/archive/2010/08/moving-tempdb.html</link>
		<comments>http://sql.richarddouglas.co.uk/archive/2010/08/moving-tempdb.html#comments</comments>
		<pubDate>Thu, 26 Aug 2010 16:43:25 +0000</pubDate>
		<dc:creator>Richard Douglas</dc:creator>
				<category><![CDATA[Server Admin]]></category>
		<category><![CDATA[TempDB]]></category>

		<guid isPermaLink="false">http://sql.richarddouglas.co.uk/?p=493</guid>
		<description><![CDATA[One of the planned projects in my schedule for the coming financial year is to add some new disks in to one of our SQL servers. As part of this project I will be moving the TempDB database onto a different disk thereby helping to reduce the IO contention on the server. [...]]]></description>
			<content:encoded><![CDATA[<p>One of the planned projects in my schedule for the coming financial year is to add some new disks in to one of our SQL servers. As part of this project I will be moving the TempDB database onto a different disk thereby helping to reduce the IO contention on the server. If you want to read more about the benefits of moving TempDB and other best practices then I suggest that you read chapter 7 (Knowing TempDB) in <a href="http://www.amazon.co.uk/Professional-Server-2008-Internals-Troubleshooting/dp/0470484284/ref=sr_1_2?ie=UTF8&amp;amp;s=books&amp;amp;qid=1268142296&amp;amp;sr=8-2" target="_blank">Professional SQL Server 2008 Internals and Troubleshooting</a>, you can read my review about it <a href="http://sql.richarddouglas.co.uk/archive/2010/03/recommended-sql-books-professional-sql-server-2008-internals-and-troubleshooting.html" target="_blank">here</a>.</p>
<p><a href="http://www.amazon.co.uk/Professional-Server-2008-Internals-Troubleshooting/dp/0470484284/ref=sr_1_2?ie=UTF8&amp;amp;s=books&amp;amp;qid=1268142296&amp;amp;sr=8-2" target="_blank"><img style="display: inline; border: 0px;" title="SQL2008InternalsandTroubleshooting" src="http://sql.richarddouglas.co.uk/wp-content/uploads/2010/08/SQL2008InternalsandTroubleshooting.jpg" border="0" alt="SQL2008InternalsandTroubleshooting" width="184" height="227" /></a></p>
<p>You may think that you need a server in order to be able to test this, but you can do this on a budget with a bog standard desktop or laptop (as long as it meets SQL Server Express’s minimum requirements) with one physical drive and a USB stick.</p>
<p>First of all insert the USB stick, ensure it&#8217;s mapped as a drive and connect to the instance on which you wish to move the  TempDB database then run the following code:</p>
<pre style="width: 99%; height: 81px;">USE master;
GO
SELECT Name, Type_Desc, File_ID, Physical_Name, Size, Growth, Is_Percent_Growth
FROM sys.master_files
WHERE database_id = DB_ID(N'tempdb');
GO</pre>
<p>This code provides the current location of the files (make sure you note this down if you are running this as a test as you will want to change it back to the original configuration) as well as the size and growth settings. The reason I am adding the extra size information in the resultset is that we are going to need to restart the instance and when the instance is restarted TempDB will be pre sized to the values shown above. You really need to check to see if these values reflect the current size of the database. You can do this one of two ways.</p>
<ol>
<li>Run the stored procedure sp_SpaceUsed whilst connected to TempDB.</li>
<li>Run the Disk Usage report for TempDB in SSMS. To do this you need to right click on TempDB, choose “Reports” then “Standard Reports” and then “Disk Usage”.</li>
</ol>
<p>I recommend using option 2 if you do not regularly check the size of your databases as the report has a feature allowing you to see recent file growth.</p>
<p>If the pre determined size is smaller than the current size then you really do need to pre size it accordingly. Again this can be done two ways, via the GUI or by the “ALTER TABLE” T-SQL command. Of course you may have the other issue where TempDB is pre sized and it will not fit onto the USB Stick, in this instance you will need to shrink the database files (never thought I would be saying that on a blog post!).</p>
<p>Now we have checked the size of TempDB it is time to move the TempDB database files onto the USB stick. In my case the USB stick has been mapped to drive “J” and I have created a directory SQLTest to hold the files. To move the files you need to use the “ALTER DATABASE” command with the “MODIFY FILE” clause:</p>
<pre>USE master;
GO
ALTER DATABASE tempdb
MODIFY FILE (NAME = tempdev, FILENAME = 'J:\SQLTest\tempdb.mdf');
GO
ALTER DATABASE tempdb
MODIFY FILE (NAME = templog, FILENAME = 'J:\SQLTest\templog.ldf');
GO</pre>
<p>Depending on the number of files you have in TempDB you will receive a message similar to the following:</p>
<p>The file &#8220;tempdev&#8221; has been modified in the system catalog. The new path will be used the next time the database is started.</p>
<p>The file &#8220;templog&#8221; has been modified in the system catalog. The new path will be used the next time the database is started.</p>
<p>I found that when I ran the first query again on my local MAPS instance (SQL Server 2008 R2 Express), it showed the TempDB database files in the new location with the correct sized files. However Books Online says that this will not happen until the service is restarted. I would still recommend restarting the service just to make sure that everything is OK.</p>
<p>After the service restart you should run the first query to make sure that everything is OK, you will then be safe to delete the old database files to free up space.</p>
<img src="http://feeds.feedburner.com/~r/co/LJKyU/~4/vsUzwp5k8cM" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://sql.richarddouglas.co.uk/archive/2010/08/moving-tempdb.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Its all about the end result</title>
		<link>http://sql.richarddouglas.co.uk/archive/2010/08/its-all-about-the-end-result.html</link>
		<comments>http://sql.richarddouglas.co.uk/archive/2010/08/its-all-about-the-end-result.html#comments</comments>
		<pubDate>Mon, 23 Aug 2010 16:35:06 +0000</pubDate>
		<dc:creator>Richard Douglas</dc:creator>
				<category><![CDATA[Server Admin]]></category>

		<guid isPermaLink="false">http://sql.richarddouglas.co.uk/?p=474</guid>
		<description><![CDATA[On Sunday night I was implementing a significant change release on our main production environment and thought after after implementing numerous implementation and migration projects over the years that a blog on the mechanics of change control could be a great help to people in their jobs, be it Developer, DBA or Project Manager. I hope there's something in here for everyone. [...]]]></description>
			<content:encoded><![CDATA[<p>On Sunday night I was implementing a significant change release on our main production environment and thought after after implementing numerous implementation and migration projects over the years that a blog on the mechanics of change control could be a great help to people in their jobs, be it Developer, DBA or Project Manager. I hope there&#8217;s something in here for everyone.</p>
<ul>
<li>Before any implementation project is considered you should have change control and source control in place. Remember the old adage failing to prepare is preparing to fail.</li>
<p> </p>
<li>Document, document, document. All areas of the implementation should be documented. This should start with the request for change document, from this a technical change document should be created. Once the change has been made and documented in the development environment you need to follow it up with a release plan. Possibly the most important but often overlooked document is the testing plan.</li>
<p> </p>
<li>You must have an extensive testing plan. Your test plan should involve unit testing each piece of code or data that is being changed. For example if your code is inserting data into a lookup table what happens if that value already exists? Will this break your application? The chances are that a duplicate value will cause significant problems. If you are able to change the schema think about adding a unique index so the insert will fail, if you are not able to make schema changes then the code should check for the existence of the value prior to inserting the data.<br />
Make sure that you have end users testing your system and that they sign off the changes have worked successfully, some companies call this User Acceptance Testing (UAT) whilst other call it Quality Assurance (QA) whatever the name it is a vital piece of work which can save hours of headaches post go live. If the end users are not happy, help them! Thomas LaRock recently wrote an entry on his <a href="http://thomaslarock.com/2010/08/dont-just-be-right-make-it-right/" target="_blank">blog</a> about making this right. In many companies I.T. is a supporting service, others call this cost centre’s so it’s important to ensure that your customers are happy with your service, it’s not enough to say “that’s what you asked for” or “I just ran the scripts I was provided with”.</li>
<p> </p>
<li>Never ever test your implementation on your live environment. You should always have an environment where you can run a test implementation. Ideally you’re implementation environment should be as up to date as possible so you have an indication of how the data will be affected in the live environment. Chances are that this environment will not to the same spec so it will not be as fast as in the live environment, it will however give you a time that the task should not exceed. You may even want to run a benchmark test with some queries that way you can extrapolate out the times to give a clearer indication of the time it will take to do each task.</li>
<p> </p>
<li>Consider what activity will be happening on the server during the implementation window.<br />
Are there any scheduled jobs that will occur during this window? Does your business require these to run at this time, can they be stopped or rescheduled? In an ideal world you would have no user access during your implementation however in this day and age a lot of companies have their own websites and one day you will find yourself implementing a change on the website’s database. Build a business case for having a maintenance window where a holding page can be put up on your website. Buy in from senior management is especially important here. If you simply cannot stop your website than make sure you have a test website connected to your test implementation environment (or at least the simulated commands) so you can look at the kind of blocking that you may face when implementing on your production environment.</li>
<p> </p>
<li>Consider the amount of data that is going to be produced during the implementation.<br />
Will you need to resize your database to prevent auto growth? Think about both the data file AND the log file.<br />
If you are using the FULL recovery mode how big are your transaction logs going to be? Will you have enough space to cope with the extra transactions on your backup drive? Would you gain from moving to BULK LOGGED mode?<br />
If you are log shipping will your destination drive have enough space for the increased size of the log files? Don’t forget that with SQL Server 2008 Enterprise Edition you can compress your log files.<br />
If you are using replication do you need to resize the distribution database accordingly?</li>
<p> </p>
<li>Rollback plans. You should never implement anything without having a way to rollback to the previous correct state. In some scenarios this may be as simple as taking a backup prior to the changes and restoring the database should anything have gone awry. For most of us however there will be activity on the server whilst we are implementing code. So you should think about auditing data changes and creating rollback scripts for each procedure/function that has been modified. Don’t forget that testing your rollback is as important as testing the implementation. Where would you be if your last backup wasn’t valid? I actually work across the road from a job centre which acts as a constant motivator for me!<br />
Knowing when to implement your rollback scripts is of paramount importance, before running any scripts at all you should discuss with the process owner the potential outcomes and ask them for their views. In other words you should set your rollback threshold levels prior to implementation. On the night there should be no need to make any major decisions as you should be fully prepared, you should however make sure that you have contact details for all the major members of the project team.</li>
<p> </p>
<li>Relax, implementations take time so make sure that you have everything that you need. You’re likely to be doing this at some unsociable hour so make sure you’re in the right state of mind. Don’t relax too much to the point of complacency as you will make mistakes. One thing a colleague did was to play a practical joke on another colleague whose favourite football team had taken a battering:
<p><a href="http://sql.richarddouglas.co.uk/wp-content/uploads/2010/08/Villaresult.jpg"><img style="display: inline; border-width: 0px;" src="http://sql.richarddouglas.co.uk/wp-content/uploads/2010/08/Villaresult_thumb.jpg" border="0" alt="" width="465" height="242" /></a><br />
It certainly lifted the mood in the office!</li>
</ul>
<img src="http://feeds.feedburner.com/~r/co/LJKyU/~4/drPjb9o6IIE" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://sql.richarddouglas.co.uk/archive/2010/08/its-all-about-the-end-result.html/feed</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Sharing scripts</title>
		<link>http://sql.richarddouglas.co.uk/archive/2010/08/sharing-scripts.html</link>
		<comments>http://sql.richarddouglas.co.uk/archive/2010/08/sharing-scripts.html#comments</comments>
		<pubDate>Sat, 21 Aug 2010 23:27:04 +0000</pubDate>
		<dc:creator>Richard Douglas</dc:creator>
				<category><![CDATA[T-SQL]]></category>
		<category><![CDATA[linkedIn]]></category>
		<category><![CDATA[TSQL Scripts]]></category>

		<guid isPermaLink="false">http://sql.richarddouglas.co.uk/?p=464</guid>
		<description><![CDATA[Most if not all SQL professionals will have heard of SQLServerCentral.com, if you haven't it's a great community site with it's own SQL Server forum where you can ask questions and receive answers from your peers. The site has a contribution center feature where registered members can submit articles, scripts and even a "Question of the day". In true community spirit I shared one of the scripts that I had been working on. [...]]]></description>
			<content:encoded><![CDATA[<p>First off I should apologise as this really should have been posted a few weeks ago when it was a little more topical, but as I mentioned in my last post <a href="http://sql.richarddouglas.co.uk/archive/2010/08/weekly-sql-blo…up-wc-20100815.html ">Weekly SQL Blog round up WC 20100815</a> unfortunately I&#8217;ve been off ill for a little while and am still catching up with a backlog of things in both my professional and family life.</p>
<p>I keep banging on about how great the SQL community is and I consider myself very lucky to work with a product where people are so keen to share their knowledge and experience with others. In fact this is the main reason that I blog &#8211; to help give something back.</p>
<p>Most if not all SQL professionals will have heard of <a href="http://www.sqlservercentral.com/">SQLServerCentral.com</a>, if you haven&#8217;t it&#8217;s a great community site with it&#8217;s own SQL Server forum where you can ask questions and receive answers from your peers. The site has a contribution center feature where registered members can submit articles, scripts and even a &#8220;Question of the day&#8221;. In true community spirit I shared one of the scripts that I had been working on. It was a great feeling when I received an email from SSC saying that my script would be published on their site. It was even listed in the daily digest email:</p>
<p><a href="http://sql.richarddouglas.co.uk/wp-content/uploads/2010/08/SSC-Database-Size-Script.png"><img class="aligncenter size-full wp-image-466" title="SSC Database Size Script" src="http://sql.richarddouglas.co.uk/wp-content/uploads/2010/08/SSC-Database-Size-Script.png" alt="" width="1036" height="176" /></a></p>
<p>The decision to publish a script on SSC rather than my own site was based on the premise that it would gain more visibility and be able to help more people than if I were to list it here on my own blog. At the time of writing this it has received over 1,200 hits in under 3 weeks which has proved that I made the right decision.</p>
<p>The script itself can be found <a href="http://www.sqlservercentral.com/scripts/T-SQL/70792/">here</a>. What the script does is to expand the functionality of sp_spaceused when you are trying to find the size of a database. If you have used sp_spaceused before you will know that it returns two result sets. My script combines these two resultsets into a single resultset but also returns the information for each database in the instance rather than just the database specified. This can really help you to monitor the size of your database over time.</p>
<p>I hope that you find the script useful, and just maybe I have even convinced you to share a script of your own with the community.</p>
<img src="http://feeds.feedburner.com/~r/co/LJKyU/~4/VLJSYyMhriw" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://sql.richarddouglas.co.uk/archive/2010/08/sharing-scripts.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Weekly SQL Blog round up WC 20100815</title>
		<link>http://sql.richarddouglas.co.uk/archive/2010/08/weekly-sql-blog-round-up-wc-20100815.html</link>
		<comments>http://sql.richarddouglas.co.uk/archive/2010/08/weekly-sql-blog-round-up-wc-20100815.html#comments</comments>
		<pubDate>Sat, 21 Aug 2010 01:00:23 +0000</pubDate>
		<dc:creator>Richard Douglas</dc:creator>
				<category><![CDATA[Round up]]></category>

		<guid isPermaLink="false">http://sql.richarddouglas.co.uk/?p=461</guid>
		<description><![CDATA[<p>In my last post I promised that I would write a weekly roundup of SQL blog entries that I have found interesting, due to illness I&#8217;ve not been able to keep that promise. I&#8217;ve been back in the office this week with lots to catch up on, as you can imagine checking out new blog entries [...]]]></description>
			<content:encoded><![CDATA[<p>In my last post I promised that I would write a weekly roundup of SQL blog entries that I have found interesting, due to illness I&#8217;ve not been able to keep that promise. I&#8217;ve been back in the office this week with lots to catch up on, as you can imagine checking out new blog entries was not my top priority.</p>
<p>Of the few posts I have been able to check out in the evenings there are a couple of posts that I just have to share:</p>
<p>Paul White has continued his rich vein of form with another great blog entry:<br />
<a href="http://sqlblog.com/blogs/paul_white/archive/2010/08/14/viewing-another-session-s-temporary-table.aspx">Viewing Another Session’s Temporary Table</a></p>
<p>Christian Bolton announced on his blog that Coeo will be giving away a Fusion IO SSD drive at SQLBits:<br />
<a href="http://sqlblogcasts.com/blogs/christian/archive/2010/08/18/coeo-are-giving-away-a-fusion-io-card-at-sqlbits.aspx">Coeo are giving away a Fusion-IO card at SQLBits</a></p>
<p>Talking about SQLBits and more importantly discount codes for attending, founding member Simon Sabin has said on his blog that if you contact him he will provide you with a discount code:<br />
<a href="http://sqlblogcasts.com/blogs/simons/archive/2010/08/18/taking-control-of-your-career-with-sql-server.aspx">Taking control of your career with SQL Server</a></p>
<p>Last but not least Buck Woody has shared a great quote which ties in nicely with the anniversary celebrations going on at the moment: <a href="http://blogs.msdn.com/b/buckwoody/archive/2010/08/20/quote-of-the-day-the-role-of-persistence.aspx">Quote of the Day: The Role of Persistence</a></p>
<img src="http://feeds.feedburner.com/~r/co/LJKyU/~4/58y30lIcXRc" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://sql.richarddouglas.co.uk/archive/2010/08/weekly-sql-blog-round-up-wc-20100815.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Weekly SQL Blog / Tweet round up</title>
		<link>http://sql.richarddouglas.co.uk/archive/2010/07/weekly-sql-blog-tweet-round-up.html</link>
		<comments>http://sql.richarddouglas.co.uk/archive/2010/07/weekly-sql-blog-tweet-round-up.html#comments</comments>
		<pubDate>Fri, 30 Jul 2010 13:30:02 +0000</pubDate>
		<dc:creator>Richard Douglas</dc:creator>
				<category><![CDATA[Round up]]></category>

		<guid isPermaLink="false">http://sql.richarddouglas.co.uk/?p=424</guid>
		<description><![CDATA[There are lots and lots of people blogging quality SQL content these days, rather than clogging up my blog and Twitter with pingbacks and retweets I thought I would start up a weekly post on the blog entries and possibly tweets that I have found interesting over the week. Due to the sheer volume of SQL content on the web it may be that some of the blog postings are quite old.
 [...]]]></description>
			<content:encoded><![CDATA[<p>There are lots and lots of people blogging quality SQL content these days, rather than clogging up my blog and Twitter account with pingbacks and retweets I thought I would start up a weekly post on the blog entries and possibly tweets that I have found interesting over the week. Due to the sheer volume of SQL content on the web it may be that some of the blog postings are quite old.</p>
<p><strong>Brad McGehee</strong> has had a couple of good blog entries this week:<br />
<a href="http://www.bradmcgehee.com/2010/07/instant-file-initialization-speeds-sql-server/">Instant File Initialization Speeds SQL Server</a> - This post is all about the benefits of having Instant File initialization set on your servers. If you&#8217;re not aware what it is then it allocates the space to the file without zeroing out the space on the disk (which may cause a security risk on shared servers). Quite a few people know about this, but it&#8217;s worth reading the comment by Jose A. Hernandez who says you can allocate the policy permission to a windows group to avoid having to add the permission to a user should the service account change &#8211; great tip!</p>
<p><a href="http://www.bradmcgehee.com/2010/07/windows-os-power-saving-feature-directly-affects-cpu-performance/">Windows OS Power Saving Feature Directly Affects CPU Performance</a> &#8211; As you may have gathered by the title this post is about Windows power setting and what direct affect it has on the CPU. After reading this I went straight to my inherited servers to check their settings. You may want to consider adding this as a step in your server setup if you do not already have it.</p>
<p><strong>Paul White</strong> &#8211; A SQL Server technical blog from the K?piti Coast, New Zealand:<br />
<a href="http://sqlblog.com/blogs/paul_white/archive/2010/07/28/the-segment-top-query-optimisation.aspx">The “Segment Top” Query Optimisation</a> &#8211; Paul&#8217;s maiden post at his new blog home on SQLBlog.com</p>
<p><strong>Simon Sabin</strong> &#8211; SimonS SQL Blog<br />
<a href="http://sqlblogcasts.com/blogs/simons/archive/2010/07/27/Want-to-support-sql-server.aspx">Want to support SQL Server ?</a> - SQL MVP Simon Sabin provides a link to career opportunities at Microsoft to work with SQL Server.</p>
<img src="http://feeds.feedburner.com/~r/co/LJKyU/~4/wDtob9yDpUc" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://sql.richarddouglas.co.uk/archive/2010/07/weekly-sql-blog-tweet-round-up.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>SQLBits – The 7 Wonders of SQL – Why you should attend</title>
		<link>http://sql.richarddouglas.co.uk/archive/2010/07/sqlbits-the-7-wonders-of-sql-why-you-should-attend.html</link>
		<comments>http://sql.richarddouglas.co.uk/archive/2010/07/sqlbits-the-7-wonders-of-sql-why-you-should-attend.html#comments</comments>
		<pubDate>Wed, 28 Jul 2010 13:01:34 +0000</pubDate>
		<dc:creator>Richard Douglas</dc:creator>
				<category><![CDATA[Career]]></category>
		<category><![CDATA[Events]]></category>
		<category><![CDATA[SQLBits]]></category>

		<guid isPermaLink="false">http://sql.richarddouglas.co.uk/?p=437</guid>
		<description><![CDATA[If you're in the U.K. and work with SQL Server chances are you have heard for this and may have even registered, for those of you who aren't subscribed to the #SQLBits twitter tag, here's a brief overview of what SQLBits is and why you should attend. [...]]]></description>
			<content:encoded><![CDATA[<p>If you&#8217;re in the U.K. and work with SQL Server chances are you have heard for this and may have even registered, for those of you who aren&#8217;t subscribed to the <a href="http://twitter.com/#search?q=%23sqlbits">#SQLBits twitter tag</a>, here&#8217;s a brief overview of what SQLBits is and why you should attend.</p>
<p>SQLBits is a not for profit organisation created by members of the SQL community for the SQL community. The first ever SQLBits was held back in October 2007, since then a further 5 have been held in various venues around the country. The idea behind this is to try and involve as many people as geographically possible by simple moving it to people who would not otherwise attend events in other UK towns and cities.</p>
<p>To give an idea of the frequency and locations of the events I&#8217;ve listed below all the previous incarnations of SQLBits:</p>
<ol>
<li>October 2007 &#8211; Reading.</li>
<li>The SQL &#8211; March 2008 &#8211; Birmingham. </li>
<li>Cubed &#8211; September 2008 &#8211; Hatfield.</li>
<li>Goes Fourth &#8211; March 2009 &#8211; Manchester &#8211; This was my first SQLBits experience.</li>
<li>Goes West &#8211; November 2009 &#8211; Newport &#8211; You can read my review of Goes West <a href="http://sql.richarddouglas.co.uk/archive/2009/11/sqlbits-review.html">here</a>.</li>
<li>The 6th Sets &#8211; April 2010 &#8211; London &#8211; I had breakfast with <a href="http://sqlblogcasts.com/blogs/christian/">Christian Bolton</a> and <a href="http://blogs.msdn.com/b/conor_cunningham_msft/">Connor Cunningham</a> at this one!</li>
</ol>
<p>The current incumbent  promises to be the biggest event ever and is considered by many to be the premier SQL Server event in Europe with many Europeans and even Americans flying in to attend.</p>
<p>Why would so many people want to attend from so far away? The reason is this, the sessions that are available have actually been voted for by the people who want to attend from an open session submission process. This means that you could submit a session to SQLBits and actually end up presenting and almost certainly guarantees a diverse and high quality programme.</p>
<p>But I&#8217;m not a DBA, would I really benefit from going to this?<br />
Yes, there are normally three or four different tracks available. At the last SQLBits the tracks were:</p>
<ul>
<li>Business Intelligence</li>
<li>DBA</li>
<li>Dev</li>
<li>SQL2008</li>
</ul>
<p>So there&#8217;s enough diversity to cater for everyone!</p>
<p>OK, I&#8217;m sold. How do I go about attending? Is it going to cost much?<br />
The event itself is going to be held over 3 days from September 30th to October 2nd. If you wish to attend the first two days then there will be a cost, but the Saturday event is totally free &#8211; they&#8217;ll even provide refreshments:</p>
<table border="0" cellspacing="2" cellpadding="4" width="100%">
<tbody>
<tr>
<td colspan="5" align="left">All prices are exclusive of VAT</td>
</tr>
<tr class="shade-light">
<td style="text-align: left;"> </td>
<td style="text-align: left;">
<div><strong>Cut-Off<br />
Date</strong><strong></strong></div>
</td>
<td style="text-align: left;">
<div><strong>Pre-Conference</strong></div>
<div>Thursday</div>
</td>
<td style="text-align: left;"><strong>7 Wonders of SQL<br />
</strong>Friday</td>
<td style="text-align: left;"><strong>Full Conference<br />
</strong>Thursday &amp; Friday</td>
<td style="text-align: left;"><strong>Community Day<br />
</strong>Saturday</td>
</tr>
<tr>
<td class="shade-light" align="left"><strong>Early Bird</strong></td>
<td style="background-color: #fff0e1;">3 Sep 2010</td>
<td style="background-color: #fff0e1;">£250.00</td>
<td style="background-color: #fff0e1;">£125.00</td>
<td style="background-color: #fff0e1;">£350.00</td>
<td style="background-color: #fff0e1;" rowspan="3"><strong>FREE</strong></td>
</tr>
<tr>
<td class="shade-light" align="left"><strong>Standard</strong></td>
<td>24 Sep 2010</td>
<td>£300.00</td>
<td>£175.00</td>
<td>£450.00</td>
</tr>
<tr>
<td class="shade-light" align="left"><strong>Last Minute</strong></td>
<td> </td>
<td>£350.00</td>
<td>£225.00</td>
<td>£550.00</td>
</tr>
</tbody>
</table>
<p><strong>Discounts available from local usergroups. Contact your usergroup organiser for<br />
details.</strong></p>
<p><strong>Extra Discount &#8211; 20% off when 6 or more people book for the whole conference.</strong></p>
<p>For more information on travel and accommodation for the conference click <a href="http://www.sqlbits.com/information/Travel.aspx">here</a>. One quick tip if you&#8217;re going by train and have a change to make look at buying a ticket for each change rather than one to the final destination, sometimes it works out cheaper and you&#8217;ll end up on the same train anyway! My wife has saved up to £30 by using this method in the past.</p>
<p>All this is only possible sue to the dedication of the founders of SQLBits and the continued support of the sponsors, I urge you to take a look at the sponsor stands if you go as not only do they sell some cool stuff that will make your jobs easier, but there are also competitions to win things like Xbox&#8217;s!</p>
<p>Finally, to register for SQLBits 7 click <a href="http://www.regonline.com/register/checkin.aspx?EventId=879908&amp;utm_campaign=RegOpen&amp;utm_medium=Blog">here</a></p>
<p>P.S. If anyone can tell me what the &#8220;7 wonders of SQL&#8221; are I&#8217;d love to know!</p>
<img src="http://feeds.feedburner.com/~r/co/LJKyU/~4/GHtm2Xl4D7Q" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://sql.richarddouglas.co.uk/archive/2010/07/sqlbits-the-7-wonders-of-sql-why-you-should-attend.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
