<?xml version="1.0" encoding="iso-8859-1"?><!-- generator="b2evolution/4.0.3" -->
<rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:admin="http://webns.net/mvcb/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:atom="http://www.w3.org/2005/Atom">
	<channel>
		<title>Data Management - Author(s): David Forck (thirster42)</title>
		<link>http://blogs.lessthandot.com/index.php/DataMgmt/</link>
		<atom:link rel="self" type="application/rss+xml" href="http://blogs.lessthandot.com/index.php/DataMgmt/?tempskin=_rss2" />
		<description></description>
		<language>en-GB</language>
		<docs>http://blogs.law.harvard.edu/tech/rss</docs>
		<admin:generatorAgent rdf:resource="http://b2evolution.net/?v=4.0.3"/>
		<ttl>60</ttl>
				<item>
			<title>Surrogate Keys Bite Back</title>
			<link>http://blogs.lessthandot.com/index.php/DataMgmt/DataDesign/surrogate-keys-bite-back</link>
			<pubDate>Wed, 15 Aug 2012 17:31:00 +0000</pubDate>			<dc:creator>David Forck (thirster42)</dc:creator>
			<category domain="main">Data Modelling &amp; Design</category>			<guid isPermaLink="false">1798@http://blogs.lessthandot.com/</guid>
						<description>&lt;p&gt;Not too long ago I got a work order in that was requesting help with removing duplicate records out of a report.  This report, and the database it was built upon, was built solely by a co-worker that left two years ago.  This report just displayed a list of project numbers and some data related to them.  I opened up the project table and voila!  I found some duplicate projects.  I noticed that the table had an identity field that was the primary key, but the project number didn&amp;#8217;t have a unique index on it, leaving the table open to allow someone to put in the same project multiple times, either on purpose or accident.&lt;/p&gt;

&lt;p&gt;I dug further, and found the query that the report was running.  The query was joining several different tables together, but not on the primary keys.  Rather, the joins were on different fields in the tables that should have been unique in their respective tables, but weren&amp;#8217;t.  This was causing reporting issues, but didn&amp;#8217;t seem to cause any issues in the application itself, which I found interesting.&lt;/p&gt;

&lt;p&gt;So, looking through the database, I collected a list of things that were wrong:&lt;br /&gt;
1.	Not using the primary key column (the id column) as the foreign key in child tables&lt;br /&gt;
2.	Not using unique indexes on fields that obviously weren&amp;#8217;t supposed to have duplicates in the table&lt;br /&gt;
3.	Joining on non-pk/fk fields expecting them to act like pk/fk fields&lt;/p&gt;


&lt;p&gt;So the takeaway from this is, if you&amp;#8217;re going to have surrogate keys (i.e. id columns) in a table, you need to utilize them so that you get proper joining logic.  You should also have unique indexes to enforce the logic that one entity (ie a project number, employee, etc.) can only have one record.&lt;/p&gt;&lt;div class=&quot;item_footer&quot;&gt;&lt;p&gt;&lt;small&gt;&lt;a href=&quot;http://blogs.lessthandot.com/index.php/DataMgmt/DataDesign/surrogate-keys-bite-back&quot;&gt;Original post&lt;/a&gt; blogged on &lt;a href=&quot;http://lessthandot.com/&quot;&gt;LessThanDot&lt;/a&gt;.&lt;/small&gt;&lt;/p&gt;&lt;/div&gt;</description>
			<content:encoded><![CDATA[<p>Not too long ago I got a work order in that was requesting help with removing duplicate records out of a report.  This report, and the database it was built upon, was built solely by a co-worker that left two years ago.  This report just displayed a list of project numbers and some data related to them.  I opened up the project table and voila!  I found some duplicate projects.  I noticed that the table had an identity field that was the primary key, but the project number didn&#8217;t have a unique index on it, leaving the table open to allow someone to put in the same project multiple times, either on purpose or accident.</p>

<p>I dug further, and found the query that the report was running.  The query was joining several different tables together, but not on the primary keys.  Rather, the joins were on different fields in the tables that should have been unique in their respective tables, but weren&#8217;t.  This was causing reporting issues, but didn&#8217;t seem to cause any issues in the application itself, which I found interesting.</p>

<p>So, looking through the database, I collected a list of things that were wrong:<br />
1.	Not using the primary key column (the id column) as the foreign key in child tables<br />
2.	Not using unique indexes on fields that obviously weren&#8217;t supposed to have duplicates in the table<br />
3.	Joining on non-pk/fk fields expecting them to act like pk/fk fields</p>


<p>So the takeaway from this is, if you&#8217;re going to have surrogate keys (i.e. id columns) in a table, you need to utilize them so that you get proper joining logic.  You should also have unique indexes to enforce the logic that one entity (ie a project number, employee, etc.) can only have one record.</p><div class="item_footer"><p><small><a href="http://blogs.lessthandot.com/index.php/DataMgmt/DataDesign/surrogate-keys-bite-back">Original post</a> blogged on <a href="http://lessthandot.com/">LessThanDot</a>.</small></p></div>]]></content:encoded>
								<comments>http://blogs.lessthandot.com/index.php/DataMgmt/DataDesign/surrogate-keys-bite-back#comments</comments>
			<wfw:commentRss>http://blogs.lessthandot.com/index.php/DataMgmt/?tempskin=_rss2&#38;disp=comments&#38;p=1798</wfw:commentRss>
		</item>
				<item>
			<title>How to create a simple cross tab report in Reporting Services 2008</title>
			<link>http://blogs.lessthandot.com/index.php/DataMgmt/ssrs/how-to-create-a-simple</link>
			<pubDate>Tue, 03 Jul 2012 16:13:00 +0000</pubDate>			<dc:creator>David Forck (thirster42)</dc:creator>
			<category domain="alt">Data Modelling &amp; Design</category>
<category domain="alt">Database Programming</category>
<category domain="main">SSRS</category>			<guid isPermaLink="false">1765@http://blogs.lessthandot.com/</guid>
						<description>&lt;p&gt;I have created several cross tab reports in the last few years.  I have also seen several hacks with different ways to achieve what is actually already built into Reporting Services.  To begin, let&amp;#8217;s define what a cross tab report is.&lt;/p&gt;


&lt;p&gt;According to Wikipedia, cross tab, or cross tabulation, means &amp;#8220;the process of creating a contingency table from the multivariate frequency distribution of statistical variables.&amp;#8221; To put that into laymen&amp;#8217;s terms, you create a grid with a group of objects on the X (horizontal) axis and another group of objects on the Y (vertical) axis, and you then tally how many occurrences those two objects meet.&lt;/p&gt;


&lt;p&gt;For example, let&amp;#8217;s say we want a cross tab of our computer inventory by department.  One axis would have our computer inventory types (desktop, laptop, tablet, smartphone) and the other axis would have our departments (IT, Finance, HR).  Here&amp;#8217;s how it might look:&lt;/p&gt;


&lt;p&gt; &lt;img src=&quot;http://blogs.lessthandot.com/media/blogs/DataMgmt/thirster42/crosstab/Sample Grid.png&quot; alt=&quot;Sample Grid&quot; title=&quot;Sample Grid&quot; /&gt;&lt;/p&gt;



&lt;p&gt;This is a pretty simple and common problem that a lot of people have to solve.  Let&amp;#8217;s take a look at this problem by starting with a database.  Create a new database and run this &lt;a href=&quot;http://textsnip.com/126ac4&quot;&gt;script&lt;/a&gt;.  It should create and populate three tables.&lt;/p&gt;


&lt;p&gt;The key to a good report is great sql code.  This simple query will power our cross tab report:&lt;/p&gt;

&lt;div class=&quot;codebox&quot;&gt;&lt;div class=&quot;codeheader&quot;&gt;Code: &lt;span&gt;tsql&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;codeholder&quot;&gt;&lt;div class=&quot;tsql&quot; id=&quot;cb86118&quot; style=&quot;display: block; color: rgb(0, 0, 0);&quot;&gt;&lt;span style=&quot;color: #0000FF;&quot;&gt;select&lt;/span&gt; &lt;br /&gt;&amp;nbsp; &amp;nbsp; it.&lt;span style=&quot;color: #202020;&quot;&gt;itName&lt;/span&gt;,&lt;br /&gt;&amp;nbsp; &amp;nbsp; d.&lt;span style=&quot;color: #202020;&quot;&gt;depName&lt;/span&gt;,&lt;br /&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #FF00FF;&quot;&gt;count&lt;/span&gt;&lt;span style=&quot;color: #808080;&quot;&gt;&amp;#40;&lt;/span&gt;i.&lt;span style=&quot;color: #202020;&quot;&gt;PK_invID&lt;/span&gt;&lt;span style=&quot;color: #808080;&quot;&gt;&amp;#41;&lt;/span&gt; &lt;span style=&quot;color: #0000FF;&quot;&gt;as&lt;/span&gt; Total&lt;br /&gt;&lt;span style=&quot;color: #0000FF;&quot;&gt;from&lt;/span&gt; dbo.&lt;span style=&quot;color: #202020;&quot;&gt;Inventory&lt;/span&gt; i&lt;br /&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #0000FF;&quot;&gt;inner&lt;/span&gt; join dbo.&lt;span style=&quot;color: #202020;&quot;&gt;InventoryTypes&lt;/span&gt; it&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #0000FF;&quot;&gt;on&lt;/span&gt; i.&lt;span style=&quot;color: #202020;&quot;&gt;FK_itID&lt;/span&gt;=it.&lt;span style=&quot;color: #202020;&quot;&gt;PK_itID&lt;/span&gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #0000FF;&quot;&gt;inner&lt;/span&gt; join dbo.&lt;span style=&quot;color: #202020;&quot;&gt;Departments&lt;/span&gt; d&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #0000FF;&quot;&gt;on&lt;/span&gt; i.&lt;span style=&quot;color: #202020;&quot;&gt;FK_depID&lt;/span&gt;=d.&lt;span style=&quot;color: #202020;&quot;&gt;PK_depID&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #0000FF;&quot;&gt;group&lt;/span&gt; &lt;span style=&quot;color: #0000FF;&quot;&gt;by&lt;/span&gt; it.&lt;span style=&quot;color: #202020;&quot;&gt;itName&lt;/span&gt;,&lt;br /&gt;&amp;nbsp; &amp;nbsp; d.&lt;span style=&quot;color: #202020;&quot;&gt;depName&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;/div&gt;&lt;div id=&quot;cb12063&quot; style=&quot;display: none; color: red;&quot;&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;This query already exists in the stored procedure dbo.CrossTab that was created in the create script.  This is the stored procedure that our report is going to use.  If you execute the stored procedure, the numbers should look faintly like the numbers in the above grid, just laid out wrong.&lt;/p&gt;

&lt;p&gt;Now that the data is set up and we&amp;#8217;ve got our query, we&amp;#8217;ll create a Report Server project in BIDS.  For simplicity&amp;#8217;s sake I&amp;#8217;m going to assume you know how to set up a project, set up a data source, set up a new report file, and set up a new dataset (using the stored procedure dbo.CrossTab).  If any of these steps have you lost, please ask for guidance on our SQL Server forum.&lt;/p&gt;

&lt;p&gt;After getting everything set up, we should have a clean report file with a data source and data set all set up and ready to go.  We&amp;#8217;ll start by dragging a matrix onto the report.  We&amp;#8217;ll then set the matrix to use the data set we set up previously (I named mine dsInventory).  &lt;/p&gt;

&lt;p&gt;I then right-click the Row Group (at the bottom of the screen, this was automatically created for us when we created the matrix), select Group Properties, and set the Group On option to [itName].  I then set the Column Group to Group on [depName].  &lt;/p&gt;

&lt;p&gt; &lt;img src=&quot;http://blogs.lessthandot.com/media/blogs/DataMgmt/thirster42/crosstab/RowGroup.png&quot; alt=&quot;Row Group&quot; title=&quot;Row Group&quot; /&gt;&lt;/p&gt;


&lt;p&gt;Next, in the matrix itself where it says rows, I insert [itName].  Where Columns is I insert [depName].  After that I insert [Sum(Total)] in the data cell.  If I then preview the report I get the exact same grid as I showed earlier, except the ordering may be wrong.&lt;/p&gt;

&lt;p&gt;That&amp;#8217;s it, that&amp;#8217;s how much it takes to make a simple cross tab in Reporting Services.  Note that the dbo.CrossTab query actually saved us some processing time by not requiring the report to figure out the total.  We could have gotten the same results if we had just selected the raw data and let the report count each instance in the cross tab, but it&amp;#8217;s a lot easier to figure out the totals in sql server than it is in reporting services in this instance. &lt;/p&gt;

&lt;p&gt;Also, if you need to have more than one grouping on an axis (say, Year then month) you would set up a child group using the Column or Row Groups with the parent group being the larger grouping (year) and the child group being the smaller grouping (month).  The designer should look something like this:&lt;/p&gt;

&lt;p&gt; &lt;img src=&quot;http://blogs.lessthandot.com/media/blogs/DataMgmt/thirster42/crosstab/PS Designer.png&quot; alt=&quot;Designer&quot; title=&quot;Designer&quot; /&gt;&lt;/p&gt;

&lt;p&gt;To summarize, some tasks are actually fairly simple to let reporting services do most of the work for you.  Getting this sort of result just in SQL Server is rather difficult and time consuming.  I hope you were able to follow along and learn a new trick that can save you time and effort on future projects.  If you have any questions please don&#039;t hesitate to ask.&lt;/p&gt;&lt;div class=&quot;item_footer&quot;&gt;&lt;p&gt;&lt;small&gt;&lt;a href=&quot;http://blogs.lessthandot.com/index.php/DataMgmt/ssrs/how-to-create-a-simple&quot;&gt;Original post&lt;/a&gt; blogged on &lt;a href=&quot;http://lessthandot.com/&quot;&gt;LessThanDot&lt;/a&gt;.&lt;/small&gt;&lt;/p&gt;&lt;/div&gt;</description>
			<content:encoded><![CDATA[<p>I have created several cross tab reports in the last few years.  I have also seen several hacks with different ways to achieve what is actually already built into Reporting Services.  To begin, let&#8217;s define what a cross tab report is.</p>


<p>According to Wikipedia, cross tab, or cross tabulation, means &#8220;the process of creating a contingency table from the multivariate frequency distribution of statistical variables.&#8221; To put that into laymen&#8217;s terms, you create a grid with a group of objects on the X (horizontal) axis and another group of objects on the Y (vertical) axis, and you then tally how many occurrences those two objects meet.</p>


<p>For example, let&#8217;s say we want a cross tab of our computer inventory by department.  One axis would have our computer inventory types (desktop, laptop, tablet, smartphone) and the other axis would have our departments (IT, Finance, HR).  Here&#8217;s how it might look:</p>


<p> <img src="http://blogs.lessthandot.com/media/blogs/DataMgmt/thirster42/crosstab/Sample Grid.png" alt="Sample Grid" title="Sample Grid" /></p>



<p>This is a pretty simple and common problem that a lot of people have to solve.  Let&#8217;s take a look at this problem by starting with a database.  Create a new database and run this <a href="http://textsnip.com/126ac4">script</a>.  It should create and populate three tables.</p>


<p>The key to a good report is great sql code.  This simple query will power our cross tab report:</p>

<div class="codebox"><div class="codeheader"><span>tsql</span><div class="codebox_javascript_links"><a href="http://blogs.lessthandot.com" onclick="linenumberOnOff('cb51549'); return false;">Line number Off</a> | <a href="http://blogs.lessthandot.com#" onclick="expandCode('cb51549','cb4276'); return false;">Hide</a> | <a href="http://blogs.lessthandot.com#" onclick="selectCode(this); return false;">Select all</a></div></div><!-- we need this dummy div to fix a firefox bug when selecting code lines --><div class="codeholder"><div class="tsql" id="cb51549" style="display: block; color: rgb(0, 0, 0);"><ol><li style="" class="li1"><span style="color: #0000FF;">select</span> </li><li style="" class="li2">&nbsp; &nbsp; it.<span style="color: #202020;">itName</span>,</li><li style="" class="li1">&nbsp; &nbsp; d.<span style="color: #202020;">depName</span>,</li><li style="" class="li2">&nbsp; &nbsp; <span style="color: #FF00FF;">count</span><span style="color: #808080;">&#40;</span>i.<span style="color: #202020;">PK_invID</span><span style="color: #808080;">&#41;</span> <span style="color: #0000FF;">as</span> Total</li><li style="" class="li1"><span style="color: #0000FF;">from</span> dbo.<span style="color: #202020;">Inventory</span> i</li><li style="" class="li2">&nbsp; &nbsp; <span style="color: #0000FF;">inner</span> join dbo.<span style="color: #202020;">InventoryTypes</span> it</li><li style="" class="li1">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0000FF;">on</span> i.<span style="color: #202020;">FK_itID</span>=it.<span style="color: #202020;">PK_itID</span></li><li style="" class="li2">&nbsp; &nbsp; <span style="color: #0000FF;">inner</span> join dbo.<span style="color: #202020;">Departments</span> d</li><li style="" class="li1">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0000FF;">on</span> i.<span style="color: #202020;">FK_depID</span>=d.<span style="color: #202020;">PK_depID</span></li><li style="" class="li2"><span style="color: #0000FF;">group</span> <span style="color: #0000FF;">by</span> it.<span style="color: #202020;">itName</span>,</li><li style="" class="li1">&nbsp; &nbsp; d.<span style="color: #202020;">depName</span></li></ol></div><div id="cb4276" style="display: none; color: red;"></div></div></div>

<p>This query already exists in the stored procedure dbo.CrossTab that was created in the create script.  This is the stored procedure that our report is going to use.  If you execute the stored procedure, the numbers should look faintly like the numbers in the above grid, just laid out wrong.</p>

<p>Now that the data is set up and we&#8217;ve got our query, we&#8217;ll create a Report Server project in BIDS.  For simplicity&#8217;s sake I&#8217;m going to assume you know how to set up a project, set up a data source, set up a new report file, and set up a new dataset (using the stored procedure dbo.CrossTab).  If any of these steps have you lost, please ask for guidance on our SQL Server forum.</p>

<p>After getting everything set up, we should have a clean report file with a data source and data set all set up and ready to go.  We&#8217;ll start by dragging a matrix onto the report.  We&#8217;ll then set the matrix to use the data set we set up previously (I named mine dsInventory).  </p>

<p>I then right-click the Row Group (at the bottom of the screen, this was automatically created for us when we created the matrix), select Group Properties, and set the Group On option to [itName].  I then set the Column Group to Group on [depName].  </p>

<p> <img src="http://blogs.lessthandot.com/media/blogs/DataMgmt/thirster42/crosstab/RowGroup.png" alt="Row Group" title="Row Group" /></p>


<p>Next, in the matrix itself where it says rows, I insert [itName].  Where Columns is I insert [depName].  After that I insert [Sum(Total)] in the data cell.  If I then preview the report I get the exact same grid as I showed earlier, except the ordering may be wrong.</p>

<p>That&#8217;s it, that&#8217;s how much it takes to make a simple cross tab in Reporting Services.  Note that the dbo.CrossTab query actually saved us some processing time by not requiring the report to figure out the total.  We could have gotten the same results if we had just selected the raw data and let the report count each instance in the cross tab, but it&#8217;s a lot easier to figure out the totals in sql server than it is in reporting services in this instance. </p>

<p>Also, if you need to have more than one grouping on an axis (say, Year then month) you would set up a child group using the Column or Row Groups with the parent group being the larger grouping (year) and the child group being the smaller grouping (month).  The designer should look something like this:</p>

<p> <img src="http://blogs.lessthandot.com/media/blogs/DataMgmt/thirster42/crosstab/PS Designer.png" alt="Designer" title="Designer" /></p>

<p>To summarize, some tasks are actually fairly simple to let reporting services do most of the work for you.  Getting this sort of result just in SQL Server is rather difficult and time consuming.  I hope you were able to follow along and learn a new trick that can save you time and effort on future projects.  If you have any questions please don't hesitate to ask.</p><div class="item_footer"><p><small><a href="http://blogs.lessthandot.com/index.php/DataMgmt/ssrs/how-to-create-a-simple">Original post</a> blogged on <a href="http://lessthandot.com/">LessThanDot</a>.</small></p></div>]]></content:encoded>
								<comments>http://blogs.lessthandot.com/index.php/DataMgmt/ssrs/how-to-create-a-simple#comments</comments>
			<wfw:commentRss>http://blogs.lessthandot.com/index.php/DataMgmt/?tempskin=_rss2&#38;disp=comments&#38;p=1765</wfw:commentRss>
		</item>
				<item>
			<title>SQL Server Developer Tips and Tricks</title>
			<link>http://blogs.lessthandot.com/index.php/DataMgmt/DBProgramming/MSSQLServer/sql-server-developer-tips-and</link>
			<pubDate>Mon, 23 Apr 2012 12:25:00 +0000</pubDate>			<dc:creator>David Forck (thirster42)</dc:creator>
			<category domain="alt">Data Modelling &amp; Design</category>
<category domain="main">Microsoft SQL Server</category>			<guid isPermaLink="false">1705@http://blogs.lessthandot.com/</guid>
						<description>&lt;p&gt;This blog is to share and highlight some of the tips and tricks that I&amp;#8217;ve learned while using SQL Server the last few years.  Some of these are code oriented, database design,  or performance oriented, while others focus on personal development. Hopefully you&#039;ll learn at least one thig from this blog.&lt;/p&gt;

&lt;h2&gt;You don&amp;#8217;t have to type out the columns&lt;/h2&gt;

&lt;p&gt;If you&amp;#8217;re using SQL Server Management Studios (SSMS) 2005 or higher, you can tell SSMS to script out select statements for you.  To do this, right-click the table, go to Script Table As &amp;#8211; Select To &amp;#8211; New Query Editor Window . You can alternatively script to the clipboard if you already have a script open and just want to paste in there .  This will open up a new window with your select statement.  &lt;/p&gt;

&lt;p&gt; &lt;img src=&quot;http://blogs.lessthandot.com/media/blogs/DataMgmt/thirster42/DevTT/devtt1.png&quot; alt=&quot;scritping select to&quot; title=&quot;scripting select to&quot; /&gt;&lt;/p&gt;


&lt;p&gt;A bonus (or down side) is that SQL Server automatically wraps each column with brackets, so if your column names have odd characters (such as spaces) this will always work.  Another bonus is consistency.  Using this method you will always be sure to have all of the columns in the table, so if you&amp;#8217;re forgetful this method is perfect for you.&lt;/p&gt;


&lt;h2&gt;Use a spreadsheet to help build your update statement&lt;/h2&gt;

&lt;p&gt;Sometimes you need to write a very long query that follows a certain pattern.  One pattern could be an update statement comparing one table to another, and updating the destination table if there are any changes.  The query could look something like this:&lt;/p&gt;

&lt;div class=&quot;codebox&quot;&gt;&lt;div class=&quot;codeheader&quot;&gt;Code: &lt;span&gt;tsql&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;codeholder&quot;&gt;&lt;div class=&quot;tsql&quot; id=&quot;cb85678&quot; style=&quot;display: block; color: rgb(0, 0, 0);&quot;&gt;&lt;span style=&quot;color: #0000FF;&quot;&gt;update&lt;/span&gt; dbo.&lt;span style=&quot;color: #202020;&quot;&gt;DestinationTable&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #0000FF;&quot;&gt;set&lt;/span&gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp; Column1 = s.&lt;span style=&quot;color: #202020;&quot;&gt;Column1&lt;/span&gt;,&lt;br /&gt;&amp;nbsp; &amp;nbsp; Column2 = s.&lt;span style=&quot;color: #202020;&quot;&gt;Column2&lt;/span&gt;,&lt;br /&gt;&amp;nbsp; &amp;nbsp; Column3 = s.&lt;span style=&quot;color: #202020;&quot;&gt;Column3&lt;/span&gt;,&lt;br /&gt;&amp;nbsp; &amp;nbsp; Column4 = s.&lt;span style=&quot;color: #202020;&quot;&gt;Column4&lt;/span&gt;,&lt;br /&gt;&amp;nbsp; &amp;nbsp; Column5 = s.&lt;span style=&quot;color: #202020;&quot;&gt;Column5&lt;/span&gt;,&lt;br /&gt;&amp;nbsp; &amp;nbsp; Column6 = s.&lt;span style=&quot;color: #202020;&quot;&gt;Column6&lt;/span&gt;,&lt;br /&gt;&amp;nbsp; &amp;nbsp; Column7 = s.&lt;span style=&quot;color: #202020;&quot;&gt;Column7&lt;/span&gt;,&lt;br /&gt;&amp;nbsp; &amp;nbsp; Column8 = s.&lt;span style=&quot;color: #202020;&quot;&gt;Column8&lt;/span&gt;,&lt;br /&gt;&amp;nbsp; &amp;nbsp; Column9 = s.&lt;span style=&quot;color: #202020;&quot;&gt;Column9&lt;/span&gt;,&lt;br /&gt;&amp;nbsp; &amp;nbsp; Column10 = s.&lt;span style=&quot;color: #202020;&quot;&gt;Column10&lt;/span&gt;&amp;nbsp; &amp;nbsp;&lt;br /&gt;&lt;span style=&quot;color: #0000FF;&quot;&gt;from&lt;/span&gt; dbo.&lt;span style=&quot;color: #202020;&quot;&gt;DestinationTable&lt;/span&gt; d&lt;br /&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #0000FF;&quot;&gt;inner&lt;/span&gt; join dbo.&lt;span style=&quot;color: #202020;&quot;&gt;SourceTable&lt;/span&gt; s&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #0000FF;&quot;&gt;on&lt;/span&gt; d.&lt;span style=&quot;color: #202020;&quot;&gt;ID&lt;/span&gt;=s.&lt;span style=&quot;color: #202020;&quot;&gt;ID&lt;/span&gt;&amp;nbsp; &amp;nbsp; &lt;br /&gt;&lt;span style=&quot;color: #0000FF;&quot;&gt;where&lt;/span&gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #FF00FF;&quot;&gt;isnull&lt;/span&gt;&lt;span style=&quot;color: #808080;&quot;&gt;&amp;#40;&lt;/span&gt;d.&lt;span style=&quot;color: #202020;&quot;&gt;Column1&lt;/span&gt;,&lt;span style=&quot;color: #FF0000;&quot;&gt;&#039;null&#039;&lt;/span&gt;&lt;span style=&quot;color: #808080;&quot;&gt;&amp;#41;&lt;/span&gt; &amp;lt;&amp;gt; &lt;span style=&quot;color: #FF00FF;&quot;&gt;isnull&lt;/span&gt;&lt;span style=&quot;color: #808080;&quot;&gt;&amp;#40;&lt;/span&gt;s.&lt;span style=&quot;color: #202020;&quot;&gt;Column1&lt;/span&gt;,&lt;span style=&quot;color: #FF0000;&quot;&gt;&#039;null&#039;&lt;/span&gt;&lt;span style=&quot;color: #808080;&quot;&gt;&amp;#41;&lt;/span&gt;&amp;nbsp; &amp;nbsp; or&lt;br /&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #FF00FF;&quot;&gt;isnull&lt;/span&gt;&lt;span style=&quot;color: #808080;&quot;&gt;&amp;#40;&lt;/span&gt;d.&lt;span style=&quot;color: #202020;&quot;&gt;Column2&lt;/span&gt;,&lt;span style=&quot;color: #FF0000;&quot;&gt;&#039;null&#039;&lt;/span&gt;&lt;span style=&quot;color: #808080;&quot;&gt;&amp;#41;&lt;/span&gt; &amp;lt;&amp;gt; &lt;span style=&quot;color: #FF00FF;&quot;&gt;isnull&lt;/span&gt;&lt;span style=&quot;color: #808080;&quot;&gt;&amp;#40;&lt;/span&gt;s.&lt;span style=&quot;color: #202020;&quot;&gt;Column2&lt;/span&gt;,&lt;span style=&quot;color: #FF0000;&quot;&gt;&#039;null&#039;&lt;/span&gt;&lt;span style=&quot;color: #808080;&quot;&gt;&amp;#41;&lt;/span&gt;&amp;nbsp; &amp;nbsp; or&lt;br /&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #FF00FF;&quot;&gt;isnull&lt;/span&gt;&lt;span style=&quot;color: #808080;&quot;&gt;&amp;#40;&lt;/span&gt;d.&lt;span style=&quot;color: #202020;&quot;&gt;Column3&lt;/span&gt;,&lt;span style=&quot;color: #FF0000;&quot;&gt;&#039;null&#039;&lt;/span&gt;&lt;span style=&quot;color: #808080;&quot;&gt;&amp;#41;&lt;/span&gt; &amp;lt;&amp;gt; &lt;span style=&quot;color: #FF00FF;&quot;&gt;isnull&lt;/span&gt;&lt;span style=&quot;color: #808080;&quot;&gt;&amp;#40;&lt;/span&gt;s.&lt;span style=&quot;color: #202020;&quot;&gt;Column3&lt;/span&gt;,&lt;span style=&quot;color: #FF0000;&quot;&gt;&#039;null&#039;&lt;/span&gt;&lt;span style=&quot;color: #808080;&quot;&gt;&amp;#41;&lt;/span&gt;&amp;nbsp; &amp;nbsp; or&lt;br /&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #FF00FF;&quot;&gt;isnull&lt;/span&gt;&lt;span style=&quot;color: #808080;&quot;&gt;&amp;#40;&lt;/span&gt;d.&lt;span style=&quot;color: #202020;&quot;&gt;Column4&lt;/span&gt;,&lt;span style=&quot;color: #FF0000;&quot;&gt;&#039;null&#039;&lt;/span&gt;&lt;span style=&quot;color: #808080;&quot;&gt;&amp;#41;&lt;/span&gt; &amp;lt;&amp;gt; &lt;span style=&quot;color: #FF00FF;&quot;&gt;isnull&lt;/span&gt;&lt;span style=&quot;color: #808080;&quot;&gt;&amp;#40;&lt;/span&gt;s.&lt;span style=&quot;color: #202020;&quot;&gt;Column4&lt;/span&gt;,&lt;span style=&quot;color: #FF0000;&quot;&gt;&#039;null&#039;&lt;/span&gt;&lt;span style=&quot;color: #808080;&quot;&gt;&amp;#41;&lt;/span&gt;&amp;nbsp; &amp;nbsp; or&lt;br /&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #FF00FF;&quot;&gt;isnull&lt;/span&gt;&lt;span style=&quot;color: #808080;&quot;&gt;&amp;#40;&lt;/span&gt;d.&lt;span style=&quot;color: #202020;&quot;&gt;Column5&lt;/span&gt;,&lt;span style=&quot;color: #FF0000;&quot;&gt;&#039;null&#039;&lt;/span&gt;&lt;span style=&quot;color: #808080;&quot;&gt;&amp;#41;&lt;/span&gt; &amp;lt;&amp;gt; &lt;span style=&quot;color: #FF00FF;&quot;&gt;isnull&lt;/span&gt;&lt;span style=&quot;color: #808080;&quot;&gt;&amp;#40;&lt;/span&gt;s.&lt;span style=&quot;color: #202020;&quot;&gt;Column5&lt;/span&gt;,&lt;span style=&quot;color: #FF0000;&quot;&gt;&#039;null&#039;&lt;/span&gt;&lt;span style=&quot;color: #808080;&quot;&gt;&amp;#41;&lt;/span&gt;&amp;nbsp; &amp;nbsp; or&lt;br /&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #FF00FF;&quot;&gt;isnull&lt;/span&gt;&lt;span style=&quot;color: #808080;&quot;&gt;&amp;#40;&lt;/span&gt;d.&lt;span style=&quot;color: #202020;&quot;&gt;Column6&lt;/span&gt;,&lt;span style=&quot;color: #FF0000;&quot;&gt;&#039;null&#039;&lt;/span&gt;&lt;span style=&quot;color: #808080;&quot;&gt;&amp;#41;&lt;/span&gt; &amp;lt;&amp;gt; &lt;span style=&quot;color: #FF00FF;&quot;&gt;isnull&lt;/span&gt;&lt;span style=&quot;color: #808080;&quot;&gt;&amp;#40;&lt;/span&gt;s.&lt;span style=&quot;color: #202020;&quot;&gt;Column6&lt;/span&gt;,&lt;span style=&quot;color: #FF0000;&quot;&gt;&#039;null&#039;&lt;/span&gt;&lt;span style=&quot;color: #808080;&quot;&gt;&amp;#41;&lt;/span&gt;&amp;nbsp; &amp;nbsp; or&lt;br /&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #FF00FF;&quot;&gt;isnull&lt;/span&gt;&lt;span style=&quot;color: #808080;&quot;&gt;&amp;#40;&lt;/span&gt;d.&lt;span style=&quot;color: #202020;&quot;&gt;Column7&lt;/span&gt;,&lt;span style=&quot;color: #FF0000;&quot;&gt;&#039;null&#039;&lt;/span&gt;&lt;span style=&quot;color: #808080;&quot;&gt;&amp;#41;&lt;/span&gt; &amp;lt;&amp;gt; &lt;span style=&quot;color: #FF00FF;&quot;&gt;isnull&lt;/span&gt;&lt;span style=&quot;color: #808080;&quot;&gt;&amp;#40;&lt;/span&gt;s.&lt;span style=&quot;color: #202020;&quot;&gt;Column7&lt;/span&gt;,&lt;span style=&quot;color: #FF0000;&quot;&gt;&#039;null&#039;&lt;/span&gt;&lt;span style=&quot;color: #808080;&quot;&gt;&amp;#41;&lt;/span&gt;&amp;nbsp; &amp;nbsp; or&lt;br /&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #FF00FF;&quot;&gt;isnull&lt;/span&gt;&lt;span style=&quot;color: #808080;&quot;&gt;&amp;#40;&lt;/span&gt;d.&lt;span style=&quot;color: #202020;&quot;&gt;Column8&lt;/span&gt;,&lt;span style=&quot;color: #FF0000;&quot;&gt;&#039;null&#039;&lt;/span&gt;&lt;span style=&quot;color: #808080;&quot;&gt;&amp;#41;&lt;/span&gt; &amp;lt;&amp;gt; &lt;span style=&quot;color: #FF00FF;&quot;&gt;isnull&lt;/span&gt;&lt;span style=&quot;color: #808080;&quot;&gt;&amp;#40;&lt;/span&gt;s.&lt;span style=&quot;color: #202020;&quot;&gt;Column8&lt;/span&gt;,&lt;span style=&quot;color: #FF0000;&quot;&gt;&#039;null&#039;&lt;/span&gt;&lt;span style=&quot;color: #808080;&quot;&gt;&amp;#41;&lt;/span&gt;&amp;nbsp; &amp;nbsp; or&lt;br /&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #FF00FF;&quot;&gt;isnull&lt;/span&gt;&lt;span style=&quot;color: #808080;&quot;&gt;&amp;#40;&lt;/span&gt;d.&lt;span style=&quot;color: #202020;&quot;&gt;Column9&lt;/span&gt;,&lt;span style=&quot;color: #FF0000;&quot;&gt;&#039;null&#039;&lt;/span&gt;&lt;span style=&quot;color: #808080;&quot;&gt;&amp;#41;&lt;/span&gt; &amp;lt;&amp;gt; &lt;span style=&quot;color: #FF00FF;&quot;&gt;isnull&lt;/span&gt;&lt;span style=&quot;color: #808080;&quot;&gt;&amp;#40;&lt;/span&gt;s.&lt;span style=&quot;color: #202020;&quot;&gt;Column9&lt;/span&gt;,&lt;span style=&quot;color: #FF0000;&quot;&gt;&#039;null&#039;&lt;/span&gt;&lt;span style=&quot;color: #808080;&quot;&gt;&amp;#41;&lt;/span&gt;&amp;nbsp; &amp;nbsp; or&lt;br /&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #FF00FF;&quot;&gt;isnull&lt;/span&gt;&lt;span style=&quot;color: #808080;&quot;&gt;&amp;#40;&lt;/span&gt;d.&lt;span style=&quot;color: #202020;&quot;&gt;Column10&lt;/span&gt;,&lt;span style=&quot;color: #FF0000;&quot;&gt;&#039;null&#039;&lt;/span&gt;&lt;span style=&quot;color: #808080;&quot;&gt;&amp;#41;&lt;/span&gt; &amp;lt;&amp;gt; &lt;span style=&quot;color: #FF00FF;&quot;&gt;isnull&lt;/span&gt;&lt;span style=&quot;color: #808080;&quot;&gt;&amp;#40;&lt;/span&gt;s.&lt;span style=&quot;color: #202020;&quot;&gt;Column10&lt;/span&gt;,&lt;span style=&quot;color: #FF0000;&quot;&gt;&#039;null&#039;&lt;/span&gt;&lt;span style=&quot;color: #808080;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;/div&gt;&lt;div id=&quot;cb22251&quot; style=&quot;display: none; color: red;&quot;&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;p&gt;	&lt;/p&gt;

&lt;p&gt;Building an update statement like this can get pretty tiring, especially if you&amp;#8217;ve got several that you need to write.  A way to speed up this process is by copying the list of columns (which can be gotten using the steps outlined in &amp;#8220;You don&amp;#8217;t have to type out the columns&amp;#8221;) into a premade spreadsheet that looks like this:&lt;/p&gt;

&lt;p&gt; &lt;img src=&quot;http://blogs.lessthandot.com/media/blogs/DataMgmt/thirster42/DevTT/devtt2.png&quot; alt=&quot;premade excel spreadsheet&quot; title=&quot;premade excel spreadsheet&quot; /&gt;&lt;/p&gt;

&lt;p&gt;You then copy the cells to the appropriate spots in your sql query and run a hand full of find and replace commands and voila, your update statement is done.&lt;/p&gt;


&lt;h2&gt;Filters are your friends&lt;/h2&gt;

&lt;p&gt;Again, if you are using SSMS and working in a large database, SSMS has the functionality to filter what objects you can see.  This makes working in a large database a lot easier because you can quickly find what you are looking for.  To do this, right click on either the Tables, Views, or Stored Procedures Folder, select Filter &amp;#8211; Filter Settings&lt;/p&gt;

&lt;p&gt; &lt;img src=&quot;http://blogs.lessthandot.com/media/blogs/DataMgmt/thirster42/DevTT/devtt3.png&quot; alt=&quot;filters!&quot; title=&quot;filters!&quot; /&gt;&lt;/p&gt;


&lt;p&gt;In the screen that pops up, you can set the filter in many different ways.&lt;/p&gt;

&lt;p&gt; &lt;img src=&quot;http://blogs.lessthandot.com/media/blogs/DataMgmt/thirster42/DevTT/devtt4.png&quot; alt=&quot;filter settings&quot; title=&quot;filter settings&quot; /&gt;&lt;/p&gt;


&lt;p&gt;Play with this to find out what works best for you.  At my organization we have what are called Code Generated Stored Procedures.  All of these stored procedure&amp;#8217;s names start with &amp;#8220;_&amp;#8221;.  So to only look at custom code I tell the filter to only show stored procedures that don&amp;#8217;t contain an underscore.&lt;/p&gt;


&lt;h2&gt;Make sure your relationships are set up&lt;/h2&gt;

&lt;p&gt;One of the easiest things to do when setting up a new database is to forget to set up the relationships between tables.  In a large database or during development of an application, it&amp;#8217;s easy to forget to set up the relationship for a new table.  LessThanDot&amp;#8217;s SQLCop has a section for detecting missing foreign keys (as well as other nifty things).  Get it for free here: &lt;a href=&quot;http://sqlcop.lessthandot.com/&quot;&gt;http://sqlcop.lessthandot.com/&lt;/a&gt;&lt;/p&gt;


&lt;h2&gt;Tools are your best friends&lt;/h2&gt;

&lt;p&gt;While SQL Server Management Studios is far and above a better tool than trying to do everything in a command prompt, it doesn&amp;#8217;t do everything for you when it comes to managing deployments.  There are several tools out there that can do this for you.  Red Gate&amp;#8217;s SQL Developer Bundle is a collection of their database tools.  It&amp;#8217;s a bit pricy, but the ROI is phenomenal and is worth having for every database developer.  They even offer a free trial.  Check it out here: &lt;a href=&quot;http://www.red-gate.com/products/sql-development/sql-developer-bundle/&quot;&gt;SQL Developer Bundle&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Another nifty tool is SQL Sentry&amp;#8217;s Plan Explorer.  Plan Explorer gives you a detailed layout of what&amp;#8217;s going on with your sql query.  It&amp;#8217;ll tell you which parts are costing the most performance wise.  There&amp;#8217;s a free version and a version you have to purchase.  Check them out here: &lt;a href=&quot;http://www.sqlsentry.net/plan-explorer/sql-server-query-view.asp&quot;&gt;SQL Server Query View&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;Get a Code Generator&lt;/h3&gt;

&lt;p&gt;Gode generators are another tool that can vastly reduce the amount of time it takes to develop a database.  Where I work at one of our application developers took the time to create an in-house code generator for our databases.  It iterates through a database and creates insert, update, delete, and select statements for each table.  This internal tool has saved us a lot of time and energy by providing a consistent base to start from.  I don&amp;#8217;t know a lot about what code generators are available, but I highly suggest trying to find one that works for you.&lt;/p&gt;



&lt;h2&gt;Don&amp;#8217;t be afraid to ask&lt;/h2&gt;

&lt;p&gt;One of the biggest mistakes a developer can do is not ask a question, no matter how small and trivial it may seem.  There are numerous resources online for getting answer.  Here&amp;#8217;s my personal list of where I go for answers:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href=&quot;http://www.lessthandot.com&quot;&gt;www.lessthandot.com&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;http://www.stackoverflow.com&quot;&gt;www.stackoverflow.com&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;http://www.dba.stackexchange.com&quot;&gt;www.dba.stackexchange.com&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;http://www.sqlservercentral.com&quot;&gt;www.sqlservercentral.com&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;https://twitter.com/#!/search/%23sqlhelp&quot;&gt;#sqlhelp on twitter&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;Follow someone&lt;/h2&gt;

&lt;p&gt;Finding someone that you greatly enjoy listening to and reading content from can greatly improve your overall abilities and knowledge pool.  About half a year after I started database development I stumbled upon SQLDenis&amp;#8217; blog on LessThanDot.  I started following him on there and I&amp;#8217;ve learned quite a bit from him.  About a year or so ago I started following Brent Ozar,  and I&amp;#8217;ve learned more about the hardware side of SQL Server and other DBA features than I would have otherwise.  Now that Kendra Little and Jeremiah Peschka are blogging for Brent Ozar PLF, the blogs on &lt;a href=&quot;http://www.brentozar.com&quot;&gt;www.brentozar.com&lt;/a&gt; have become even more diverse.&lt;/p&gt;

&lt;p&gt;The SQL Server community is blessed with many active community members that are more than willing to share their knowledge with the rest of the world.  Follow one of them and you&amp;#8217;ll be thanking yourself later.&lt;/p&gt;

&lt;p&gt;Ted Krueger wrote a blog about mentors and mentoring here: &lt;a href=&quot;http://blogs.lessthandot.com/index.php/ITProfessionals/ProfessionalDevelopment/mentoring-as-i-see-it&quot;&gt;Mentoring As I See It&lt;/a&gt;&lt;/p&gt;



&lt;h2&gt;Schemas, it&amp;#8217;s what&amp;#8217;s for dinner&lt;/h2&gt;

&lt;p&gt;In SQL Server 2005+, you can break out tables, views, and stored procedures into schemas.  A schema is a security object that allows you to separate objects, similar to folders on your hard drive.  You can&amp;#8217;t nest schemas though, but they are still pretty nifty.  This leans a bit more towards administration, but I believe that database developers should know how to utilize schemas.&lt;/p&gt;

&lt;p&gt;Let&amp;#8217;s say you&amp;#8217;ve got a database with 10 tables, and out of those 10 tables your users can insert, update, and delete against 5 of them.  The other 5 they can only read from.  In a database where they&amp;#8217;re all in the dbo schema, it&amp;#8217;d look something like this:&lt;/p&gt;

&lt;p&gt; &lt;img src=&quot;http://blogs.lessthandot.com/media/blogs/DataMgmt/thirster42/DevTT/devtt5.png&quot; alt=&quot;tables without schemas&quot; title=&quot;tables without schemas&quot; /&gt;&lt;/p&gt;

&lt;p&gt;To set up proper security you&amp;#8217;d have to assign security by table (read permissions and read/write permissions).  This is somewhat messy and doesn&amp;#8217;t update if new tables are added.  A better way is to break the tables into two schemas, a read only schema and a read/write schema.  The following is an example of how it could look:&lt;/p&gt;

&lt;p&gt; &lt;img src=&quot;http://blogs.lessthandot.com/media/blogs/DataMgmt/thirster42/DevTT/devtt6.png&quot; alt=&quot;tables with schemas&quot; title=&quot;tables with schemas&quot; /&gt;&lt;/p&gt;

&lt;p&gt;With this set up, you can now assign security at the schema level, and every new table added now has security set up on it.  Easy, right?  Play with schemas and see how you can utilize them to your advantage.&lt;/p&gt;




&lt;h2&gt;Fine Tune SSMS Options&lt;/h2&gt;

&lt;p&gt;SQL Server Management Studios has a lot of options to play with.  One option that I have disabled is the &amp;#8220;Use [database]&amp;#8221; statement that you get whenever you script out a table.  To change this I went to Tools &amp;#8211; Options.  Then went to SQL Server Object Explorer &amp;#8211; Scripting, and changed &amp;#8220;Script USE [database]&amp;#8221; to false.&lt;/p&gt;

&lt;p&gt; &lt;img src=&quot;http://blogs.lessthandot.com/media/blogs/DataMgmt/thirster42/DevTT/devtt7.png&quot; alt=&quot;getting to the options&quot; title=&quot;getting to the options&quot; /&gt;&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;http://blogs.lessthandot.com/media/blogs/DataMgmt/thirster42/DevTT/devtt8.png&quot; alt=&quot;options window&quot; title=&quot;options window&quot; /&gt;&lt;/p&gt;

&lt;p&gt; &lt;/p&gt;

&lt;p&gt;There are loads of options that you can choose from.  Some examples include:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Hiding system objects in Object Explorer&lt;/li&gt;
&lt;li&gt;Enabling/disabling Line Numbers&lt;/li&gt;
&lt;li&gt;Advanced execution settings (set nocount, set noexec, etc.)&lt;/li&gt;
&lt;li&gt;Results to Grid, Text, or File&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;That&#039;s all that I can think of for now.  If you&#039;ve got any tips or tricks, or a favorite person that you follow, please share it in the comments below, or even write your own blog and link us to it.&lt;/p&gt;&lt;div class=&quot;item_footer&quot;&gt;&lt;p&gt;&lt;small&gt;&lt;a href=&quot;http://blogs.lessthandot.com/index.php/DataMgmt/DBProgramming/MSSQLServer/sql-server-developer-tips-and&quot;&gt;Original post&lt;/a&gt; blogged on &lt;a href=&quot;http://lessthandot.com/&quot;&gt;LessThanDot&lt;/a&gt;.&lt;/small&gt;&lt;/p&gt;&lt;/div&gt;</description>
			<content:encoded><![CDATA[<p>This blog is to share and highlight some of the tips and tricks that I&#8217;ve learned while using SQL Server the last few years.  Some of these are code oriented, database design,  or performance oriented, while others focus on personal development. Hopefully you'll learn at least one thig from this blog.</p>

<h2>You don&#8217;t have to type out the columns</h2>

<p>If you&#8217;re using SQL Server Management Studios (SSMS) 2005 or higher, you can tell SSMS to script out select statements for you.  To do this, right-click the table, go to Script Table As &#8211; Select To &#8211; New Query Editor Window . You can alternatively script to the clipboard if you already have a script open and just want to paste in there .  This will open up a new window with your select statement.  </p>

<p> <img src="http://blogs.lessthandot.com/media/blogs/DataMgmt/thirster42/DevTT/devtt1.png" alt="scritping select to" title="scripting select to" /></p>


<p>A bonus (or down side) is that SQL Server automatically wraps each column with brackets, so if your column names have odd characters (such as spaces) this will always work.  Another bonus is consistency.  Using this method you will always be sure to have all of the columns in the table, so if you&#8217;re forgetful this method is perfect for you.</p>


<h2>Use a spreadsheet to help build your update statement</h2>

<p>Sometimes you need to write a very long query that follows a certain pattern.  One pattern could be an update statement comparing one table to another, and updating the destination table if there are any changes.  The query could look something like this:</p>

<div class="codebox"><div class="codeheader"><span>tsql</span><div class="codebox_javascript_links"><a href="http://blogs.lessthandot.com" onclick="linenumberOnOff('cb27562'); return false;">Line number Off</a> | <a href="http://blogs.lessthandot.com#" onclick="expandCode('cb27562','cb57188'); return false;">Hide</a> | <a href="http://blogs.lessthandot.com#" onclick="selectCode(this); return false;">Select all</a></div></div><!-- we need this dummy div to fix a firefox bug when selecting code lines --><div class="codeholder"><div class="tsql" id="cb27562" style="display: block; color: rgb(0, 0, 0);"><ol><li style="" class="li1"><span style="color: #0000FF;">update</span> dbo.<span style="color: #202020;">DestinationTable</span></li><li style="" class="li2"><span style="color: #0000FF;">set</span></li><li style="" class="li1">&nbsp; &nbsp; Column1 = s.<span style="color: #202020;">Column1</span>,</li><li style="" class="li2">&nbsp; &nbsp; Column2 = s.<span style="color: #202020;">Column2</span>,</li><li style="" class="li1">&nbsp; &nbsp; Column3 = s.<span style="color: #202020;">Column3</span>,</li><li style="" class="li2">&nbsp; &nbsp; Column4 = s.<span style="color: #202020;">Column4</span>,</li><li style="" class="li1">&nbsp; &nbsp; Column5 = s.<span style="color: #202020;">Column5</span>,</li><li style="" class="li2">&nbsp; &nbsp; Column6 = s.<span style="color: #202020;">Column6</span>,</li><li style="" class="li1">&nbsp; &nbsp; Column7 = s.<span style="color: #202020;">Column7</span>,</li><li style="" class="li2">&nbsp; &nbsp; Column8 = s.<span style="color: #202020;">Column8</span>,</li><li style="" class="li1">&nbsp; &nbsp; Column9 = s.<span style="color: #202020;">Column9</span>,</li><li style="" class="li2">&nbsp; &nbsp; Column10 = s.<span style="color: #202020;">Column10</span>&nbsp; &nbsp;</li><li style="" class="li1"><span style="color: #0000FF;">from</span> dbo.<span style="color: #202020;">DestinationTable</span> d</li><li style="" class="li2">&nbsp; &nbsp; <span style="color: #0000FF;">inner</span> join dbo.<span style="color: #202020;">SourceTable</span> s</li><li style="" class="li1">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0000FF;">on</span> d.<span style="color: #202020;">ID</span>=s.<span style="color: #202020;">ID</span>&nbsp; &nbsp; </li><li style="" class="li2"><span style="color: #0000FF;">where</span></li><li style="" class="li1">&nbsp; &nbsp; <span style="color: #FF00FF;">isnull</span><span style="color: #808080;">&#40;</span>d.<span style="color: #202020;">Column1</span>,<span style="color: #FF0000;">'null'</span><span style="color: #808080;">&#41;</span> &lt;&gt; <span style="color: #FF00FF;">isnull</span><span style="color: #808080;">&#40;</span>s.<span style="color: #202020;">Column1</span>,<span style="color: #FF0000;">'null'</span><span style="color: #808080;">&#41;</span>&nbsp; &nbsp; or</li><li style="" class="li2">&nbsp; &nbsp; <span style="color: #FF00FF;">isnull</span><span style="color: #808080;">&#40;</span>d.<span style="color: #202020;">Column2</span>,<span style="color: #FF0000;">'null'</span><span style="color: #808080;">&#41;</span> &lt;&gt; <span style="color: #FF00FF;">isnull</span><span style="color: #808080;">&#40;</span>s.<span style="color: #202020;">Column2</span>,<span style="color: #FF0000;">'null'</span><span style="color: #808080;">&#41;</span>&nbsp; &nbsp; or</li><li style="" class="li1">&nbsp; &nbsp; <span style="color: #FF00FF;">isnull</span><span style="color: #808080;">&#40;</span>d.<span style="color: #202020;">Column3</span>,<span style="color: #FF0000;">'null'</span><span style="color: #808080;">&#41;</span> &lt;&gt; <span style="color: #FF00FF;">isnull</span><span style="color: #808080;">&#40;</span>s.<span style="color: #202020;">Column3</span>,<span style="color: #FF0000;">'null'</span><span style="color: #808080;">&#41;</span>&nbsp; &nbsp; or</li><li style="" class="li2">&nbsp; &nbsp; <span style="color: #FF00FF;">isnull</span><span style="color: #808080;">&#40;</span>d.<span style="color: #202020;">Column4</span>,<span style="color: #FF0000;">'null'</span><span style="color: #808080;">&#41;</span> &lt;&gt; <span style="color: #FF00FF;">isnull</span><span style="color: #808080;">&#40;</span>s.<span style="color: #202020;">Column4</span>,<span style="color: #FF0000;">'null'</span><span style="color: #808080;">&#41;</span>&nbsp; &nbsp; or</li><li style="" class="li1">&nbsp; &nbsp; <span style="color: #FF00FF;">isnull</span><span style="color: #808080;">&#40;</span>d.<span style="color: #202020;">Column5</span>,<span style="color: #FF0000;">'null'</span><span style="color: #808080;">&#41;</span> &lt;&gt; <span style="color: #FF00FF;">isnull</span><span style="color: #808080;">&#40;</span>s.<span style="color: #202020;">Column5</span>,<span style="color: #FF0000;">'null'</span><span style="color: #808080;">&#41;</span>&nbsp; &nbsp; or</li><li style="" class="li2">&nbsp; &nbsp; <span style="color: #FF00FF;">isnull</span><span style="color: #808080;">&#40;</span>d.<span style="color: #202020;">Column6</span>,<span style="color: #FF0000;">'null'</span><span style="color: #808080;">&#41;</span> &lt;&gt; <span style="color: #FF00FF;">isnull</span><span style="color: #808080;">&#40;</span>s.<span style="color: #202020;">Column6</span>,<span style="color: #FF0000;">'null'</span><span style="color: #808080;">&#41;</span>&nbsp; &nbsp; or</li><li style="" class="li1">&nbsp; &nbsp; <span style="color: #FF00FF;">isnull</span><span style="color: #808080;">&#40;</span>d.<span style="color: #202020;">Column7</span>,<span style="color: #FF0000;">'null'</span><span style="color: #808080;">&#41;</span> &lt;&gt; <span style="color: #FF00FF;">isnull</span><span style="color: #808080;">&#40;</span>s.<span style="color: #202020;">Column7</span>,<span style="color: #FF0000;">'null'</span><span style="color: #808080;">&#41;</span>&nbsp; &nbsp; or</li><li style="" class="li2">&nbsp; &nbsp; <span style="color: #FF00FF;">isnull</span><span style="color: #808080;">&#40;</span>d.<span style="color: #202020;">Column8</span>,<span style="color: #FF0000;">'null'</span><span style="color: #808080;">&#41;</span> &lt;&gt; <span style="color: #FF00FF;">isnull</span><span style="color: #808080;">&#40;</span>s.<span style="color: #202020;">Column8</span>,<span style="color: #FF0000;">'null'</span><span style="color: #808080;">&#41;</span>&nbsp; &nbsp; or</li><li style="" class="li1">&nbsp; &nbsp; <span style="color: #FF00FF;">isnull</span><span style="color: #808080;">&#40;</span>d.<span style="color: #202020;">Column9</span>,<span style="color: #FF0000;">'null'</span><span style="color: #808080;">&#41;</span> &lt;&gt; <span style="color: #FF00FF;">isnull</span><span style="color: #808080;">&#40;</span>s.<span style="color: #202020;">Column9</span>,<span style="color: #FF0000;">'null'</span><span style="color: #808080;">&#41;</span>&nbsp; &nbsp; or</li><li style="" class="li2">&nbsp; &nbsp; <span style="color: #FF00FF;">isnull</span><span style="color: #808080;">&#40;</span>d.<span style="color: #202020;">Column10</span>,<span style="color: #FF0000;">'null'</span><span style="color: #808080;">&#41;</span> &lt;&gt; <span style="color: #FF00FF;">isnull</span><span style="color: #808080;">&#40;</span>s.<span style="color: #202020;">Column10</span>,<span style="color: #FF0000;">'null'</span><span style="color: #808080;">&#41;</span></li></ol></div><div id="cb57188" style="display: none; color: red;"></div></div></div><p>	</p>

<p>Building an update statement like this can get pretty tiring, especially if you&#8217;ve got several that you need to write.  A way to speed up this process is by copying the list of columns (which can be gotten using the steps outlined in &#8220;You don&#8217;t have to type out the columns&#8221;) into a premade spreadsheet that looks like this:</p>

<p> <img src="http://blogs.lessthandot.com/media/blogs/DataMgmt/thirster42/DevTT/devtt2.png" alt="premade excel spreadsheet" title="premade excel spreadsheet" /></p>

<p>You then copy the cells to the appropriate spots in your sql query and run a hand full of find and replace commands and voila, your update statement is done.</p>


<h2>Filters are your friends</h2>

<p>Again, if you are using SSMS and working in a large database, SSMS has the functionality to filter what objects you can see.  This makes working in a large database a lot easier because you can quickly find what you are looking for.  To do this, right click on either the Tables, Views, or Stored Procedures Folder, select Filter &#8211; Filter Settings</p>

<p> <img src="http://blogs.lessthandot.com/media/blogs/DataMgmt/thirster42/DevTT/devtt3.png" alt="filters!" title="filters!" /></p>


<p>In the screen that pops up, you can set the filter in many different ways.</p>

<p> <img src="http://blogs.lessthandot.com/media/blogs/DataMgmt/thirster42/DevTT/devtt4.png" alt="filter settings" title="filter settings" /></p>


<p>Play with this to find out what works best for you.  At my organization we have what are called Code Generated Stored Procedures.  All of these stored procedure&#8217;s names start with &#8220;_&#8221;.  So to only look at custom code I tell the filter to only show stored procedures that don&#8217;t contain an underscore.</p>


<h2>Make sure your relationships are set up</h2>

<p>One of the easiest things to do when setting up a new database is to forget to set up the relationships between tables.  In a large database or during development of an application, it&#8217;s easy to forget to set up the relationship for a new table.  LessThanDot&#8217;s SQLCop has a section for detecting missing foreign keys (as well as other nifty things).  Get it for free here: <a href="http://sqlcop.lessthandot.com/">http://sqlcop.lessthandot.com/</a></p>


<h2>Tools are your best friends</h2>

<p>While SQL Server Management Studios is far and above a better tool than trying to do everything in a command prompt, it doesn&#8217;t do everything for you when it comes to managing deployments.  There are several tools out there that can do this for you.  Red Gate&#8217;s SQL Developer Bundle is a collection of their database tools.  It&#8217;s a bit pricy, but the ROI is phenomenal and is worth having for every database developer.  They even offer a free trial.  Check it out here: <a href="http://www.red-gate.com/products/sql-development/sql-developer-bundle/">SQL Developer Bundle</a></p>

<p>Another nifty tool is SQL Sentry&#8217;s Plan Explorer.  Plan Explorer gives you a detailed layout of what&#8217;s going on with your sql query.  It&#8217;ll tell you which parts are costing the most performance wise.  There&#8217;s a free version and a version you have to purchase.  Check them out here: <a href="http://www.sqlsentry.net/plan-explorer/sql-server-query-view.asp">SQL Server Query View</a></p>

<h3>Get a Code Generator</h3>

<p>Gode generators are another tool that can vastly reduce the amount of time it takes to develop a database.  Where I work at one of our application developers took the time to create an in-house code generator for our databases.  It iterates through a database and creates insert, update, delete, and select statements for each table.  This internal tool has saved us a lot of time and energy by providing a consistent base to start from.  I don&#8217;t know a lot about what code generators are available, but I highly suggest trying to find one that works for you.</p>



<h2>Don&#8217;t be afraid to ask</h2>

<p>One of the biggest mistakes a developer can do is not ask a question, no matter how small and trivial it may seem.  There are numerous resources online for getting answer.  Here&#8217;s my personal list of where I go for answers:</p>
<ul>
<li><a href="http://www.lessthandot.com">www.lessthandot.com</a></li>
<li><a href="http://www.stackoverflow.com">www.stackoverflow.com</a></li>
<li><a href="http://www.dba.stackexchange.com">www.dba.stackexchange.com</a></li>
<li><a href="http://www.sqlservercentral.com">www.sqlservercentral.com</a></li>
<li><a href="https://twitter.com/#!/search/%23sqlhelp">#sqlhelp on twitter</a></li>
</ul>

<h2>Follow someone</h2>

<p>Finding someone that you greatly enjoy listening to and reading content from can greatly improve your overall abilities and knowledge pool.  About half a year after I started database development I stumbled upon SQLDenis&#8217; blog on LessThanDot.  I started following him on there and I&#8217;ve learned quite a bit from him.  About a year or so ago I started following Brent Ozar,  and I&#8217;ve learned more about the hardware side of SQL Server and other DBA features than I would have otherwise.  Now that Kendra Little and Jeremiah Peschka are blogging for Brent Ozar PLF, the blogs on <a href="http://www.brentozar.com">www.brentozar.com</a> have become even more diverse.</p>

<p>The SQL Server community is blessed with many active community members that are more than willing to share their knowledge with the rest of the world.  Follow one of them and you&#8217;ll be thanking yourself later.</p>

<p>Ted Krueger wrote a blog about mentors and mentoring here: <a href="http://blogs.lessthandot.com/index.php/ITProfessionals/ProfessionalDevelopment/mentoring-as-i-see-it">Mentoring As I See It</a></p>



<h2>Schemas, it&#8217;s what&#8217;s for dinner</h2>

<p>In SQL Server 2005+, you can break out tables, views, and stored procedures into schemas.  A schema is a security object that allows you to separate objects, similar to folders on your hard drive.  You can&#8217;t nest schemas though, but they are still pretty nifty.  This leans a bit more towards administration, but I believe that database developers should know how to utilize schemas.</p>

<p>Let&#8217;s say you&#8217;ve got a database with 10 tables, and out of those 10 tables your users can insert, update, and delete against 5 of them.  The other 5 they can only read from.  In a database where they&#8217;re all in the dbo schema, it&#8217;d look something like this:</p>

<p> <img src="http://blogs.lessthandot.com/media/blogs/DataMgmt/thirster42/DevTT/devtt5.png" alt="tables without schemas" title="tables without schemas" /></p>

<p>To set up proper security you&#8217;d have to assign security by table (read permissions and read/write permissions).  This is somewhat messy and doesn&#8217;t update if new tables are added.  A better way is to break the tables into two schemas, a read only schema and a read/write schema.  The following is an example of how it could look:</p>

<p> <img src="http://blogs.lessthandot.com/media/blogs/DataMgmt/thirster42/DevTT/devtt6.png" alt="tables with schemas" title="tables with schemas" /></p>

<p>With this set up, you can now assign security at the schema level, and every new table added now has security set up on it.  Easy, right?  Play with schemas and see how you can utilize them to your advantage.</p>




<h2>Fine Tune SSMS Options</h2>

<p>SQL Server Management Studios has a lot of options to play with.  One option that I have disabled is the &#8220;Use [database]&#8221; statement that you get whenever you script out a table.  To change this I went to Tools &#8211; Options.  Then went to SQL Server Object Explorer &#8211; Scripting, and changed &#8220;Script USE [database]&#8221; to false.</p>

<p> <img src="http://blogs.lessthandot.com/media/blogs/DataMgmt/thirster42/DevTT/devtt7.png" alt="getting to the options" title="getting to the options" /></p>

<p><img src="http://blogs.lessthandot.com/media/blogs/DataMgmt/thirster42/DevTT/devtt8.png" alt="options window" title="options window" /></p>

<p> </p>

<p>There are loads of options that you can choose from.  Some examples include:</p>
<ul>
<li>Hiding system objects in Object Explorer</li>
<li>Enabling/disabling Line Numbers</li>
<li>Advanced execution settings (set nocount, set noexec, etc.)</li>
<li>Results to Grid, Text, or File</li>
</ul>

<p>That's all that I can think of for now.  If you've got any tips or tricks, or a favorite person that you follow, please share it in the comments below, or even write your own blog and link us to it.</p><div class="item_footer"><p><small><a href="http://blogs.lessthandot.com/index.php/DataMgmt/DBProgramming/MSSQLServer/sql-server-developer-tips-and">Original post</a> blogged on <a href="http://lessthandot.com/">LessThanDot</a>.</small></p></div>]]></content:encoded>
								<comments>http://blogs.lessthandot.com/index.php/DataMgmt/DBProgramming/MSSQLServer/sql-server-developer-tips-and#comments</comments>
			<wfw:commentRss>http://blogs.lessthandot.com/index.php/DataMgmt/?tempskin=_rss2&#38;disp=comments&#38;p=1705</wfw:commentRss>
		</item>
				<item>
			<title>Managing your filegroups</title>
			<link>http://blogs.lessthandot.com/index.php/DataMgmt/DataDesign/managing-your-filegroups</link>
			<pubDate>Fri, 23 Mar 2012 12:29:00 +0000</pubDate>			<dc:creator>David Forck (thirster42)</dc:creator>
			<category domain="main">Data Modelling &amp; Design</category>			<guid isPermaLink="false">1674@http://blogs.lessthandot.com/</guid>
						<description>&lt;div&gt;&lt;div&gt;&lt;a href=&quot;http://blogs.lessthandot.com/media/blogs/DataMgmt/thirster42/DatabaseFG.png?mtime=1332444141&quot;&gt;&lt;img alt=&quot;&quot; src=&quot;http://blogs.lessthandot.com/media/blogs/DataMgmt/thirster42/.evocache/DatabaseFG.png/fit-320x320.png?mtime=1332444141&quot; width=&quot;248&quot; height=&quot;283&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;/div&gt;&lt;p&gt;It&amp;#8217;s 4 PM; do you know what&#039;s in your filegroups?&lt;/p&gt;

&lt;p&gt;I found myself having this inner monologue the other day after I pushed a database form dev to test.  On the dev server I had split the database into two filegroups, one to store the data for the staging tables, and one to store the data for the end results.  The files essentially looked like this:&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;http://blogs.lessthandot.com/media/blogs/DataMgmt/thirster42/FG1.png&quot; alt=&quot;Database Files&quot; title=&quot;Database Files&quot; /&gt;&lt;/p&gt;


&lt;p&gt;I realized that I hadn&amp;#8217;t generated the file groups or extra files on the second server.  I created them and then used this query to find out where the tables and indexes were:&lt;/p&gt;


&lt;div class=&quot;codebox&quot;&gt;&lt;div class=&quot;codeheader&quot;&gt;Code: &lt;span&gt;tsql&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;codeholder&quot;&gt;&lt;div class=&quot;tsql&quot; id=&quot;cb1187&quot; style=&quot;display: block; color: rgb(0, 0, 0);&quot;&gt;&lt;span style=&quot;color: #0000FF;&quot;&gt;select&lt;/span&gt; &lt;span style=&quot;color: #0000FF;&quot;&gt;distinct&lt;/span&gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp; s.&lt;span style=&quot;color: #202020;&quot;&gt;name&lt;/span&gt; &lt;span style=&quot;color: #0000FF;&quot;&gt;as&lt;/span&gt; SchemaName,&lt;br /&gt;&amp;nbsp; &amp;nbsp; t.&lt;span style=&quot;color: #202020;&quot;&gt;name&lt;/span&gt; &lt;span style=&quot;color: #0000FF;&quot;&gt;as&lt;/span&gt; TableName,&lt;br /&gt;&amp;nbsp; &amp;nbsp; i.&lt;span style=&quot;color: #202020;&quot;&gt;name&lt;/span&gt; &lt;span style=&quot;color: #0000FF;&quot;&gt;as&lt;/span&gt; IndexName,&lt;br /&gt;&amp;nbsp; &amp;nbsp; fg.&lt;span style=&quot;color: #202020;&quot;&gt;name&lt;/span&gt; &lt;span style=&quot;color: #0000FF;&quot;&gt;as&lt;/span&gt; FileGroupName&lt;br /&gt;&lt;span style=&quot;color: #0000FF;&quot;&gt;from&lt;/span&gt; &lt;span style=&quot;color: #00AF00;&quot;&gt;sys&lt;/span&gt;.&lt;span style=&quot;color: #00AF00;&quot;&gt;tables&lt;/span&gt; t&lt;br /&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #0000FF;&quot;&gt;inner&lt;/span&gt; join &lt;span style=&quot;color: #00AF00;&quot;&gt;sys&lt;/span&gt;.&lt;span style=&quot;color: #00AF00;&quot;&gt;indexes&lt;/span&gt; i&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #0000FF;&quot;&gt;on&lt;/span&gt; t.&lt;span style=&quot;color: #FF00FF;&quot;&gt;object_id&lt;/span&gt;=i.&lt;span style=&quot;color: #FF00FF;&quot;&gt;object_id&lt;/span&gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #0000FF;&quot;&gt;inner&lt;/span&gt; join &lt;span style=&quot;color: #00AF00;&quot;&gt;sys&lt;/span&gt;.&lt;span style=&quot;color: #00AF00;&quot;&gt;schemas&lt;/span&gt; s&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #0000FF;&quot;&gt;on&lt;/span&gt; t.&lt;span style=&quot;color: #FF00FF;&quot;&gt;schema_id&lt;/span&gt;=s.&lt;span style=&quot;color: #FF00FF;&quot;&gt;schema_id&lt;/span&gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #0000FF;&quot;&gt;inner&lt;/span&gt; join &lt;span style=&quot;color: #00AF00;&quot;&gt;sys&lt;/span&gt;.&lt;span style=&quot;color: #00AF00;&quot;&gt;filegroups&lt;/span&gt; fg&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #0000FF;&quot;&gt;on&lt;/span&gt; i.&lt;span style=&quot;color: #202020;&quot;&gt;data_space_id&lt;/span&gt;=fg.&lt;span style=&quot;color: #202020;&quot;&gt;data_space_id&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #0000FF;&quot;&gt;order&lt;/span&gt; &lt;span style=&quot;color: #0000FF;&quot;&gt;by&lt;/span&gt; s.&lt;span style=&quot;color: #202020;&quot;&gt;name&lt;/span&gt;, t.&lt;span style=&quot;color: #202020;&quot;&gt;name&lt;/span&gt;, fg.&lt;span style=&quot;color: #202020;&quot;&gt;name&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;/div&gt;&lt;div id=&quot;cb89715&quot; style=&quot;display: none; color: red;&quot;&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;In SSMS, as long as you don&amp;#8217;t have a lot of data in the table, the tables (aka the clustered indexes) are easy to move.  Just right click- design on the table and change the filegroup (and text/image filegroup) to secondary and save.  &lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;http://blogs.lessthandot.com/media/blogs/DataMgmt/thirster42/FG2.png&quot; alt=&quot;Properties&quot; title=&quot;Properties&quot; /&gt;&lt;br /&gt;
 &lt;/p&gt;


&lt;p&gt;Behind the scenes SSMS will create a new table with the same structure on the filegroup, copy the data, drop the old table and rename the new table to the appropriate name.  Now do you see why it matters how much data you have?  If you&amp;#8217;ve got a lot of data then you need to drop the Clustered index, move it, and then recreate the Clustered Index.&lt;/p&gt;

&lt;div class=&quot;codebox&quot;&gt;&lt;div class=&quot;codeheader&quot;&gt;Code: &lt;span&gt;tsql&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;codeholder&quot;&gt;&lt;div class=&quot;tsql&quot; id=&quot;cb85481&quot; style=&quot;display: block; color: rgb(0, 0, 0);&quot;&gt;&lt;span style=&quot;color: #0000FF;&quot;&gt;ALTER&lt;/span&gt; &lt;span style=&quot;color: #0000FF;&quot;&gt;TABLE&lt;/span&gt; dbo.&lt;span style=&quot;color: #202020;&quot;&gt;Blah&lt;/span&gt; &lt;span style=&quot;color: #0000FF;&quot;&gt;DROP&lt;/span&gt; &lt;span style=&quot;color: #0000FF;&quot;&gt;CONSTRAINT&lt;/span&gt; PK_Blah &lt;span style=&quot;color: #0000FF;&quot;&gt;WITH&lt;/span&gt; &lt;span style=&quot;color: #808080;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #0000FF;&quot;&gt;MOVE&lt;/span&gt; &lt;span style=&quot;color: #0000FF;&quot;&gt;TO&lt;/span&gt; Secondary&lt;span style=&quot;color: #808080;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #0000FF;&quot;&gt;GO&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #0000FF;&quot;&gt;ALTER&lt;/span&gt; &lt;span style=&quot;color: #0000FF;&quot;&gt;TABLE&lt;/span&gt; dbo.&lt;span style=&quot;color: #202020;&quot;&gt;Blah&lt;/span&gt; &lt;span style=&quot;color: #0000FF;&quot;&gt;ADD&lt;/span&gt; &lt;span style=&quot;color: #0000FF;&quot;&gt;CONSTRAINT&lt;/span&gt; PK_Blah &lt;span style=&quot;color: #0000FF;&quot;&gt;PRIMARY&lt;/span&gt; &lt;span style=&quot;color: #0000FF;&quot;&gt;KEY&lt;/span&gt;&lt;span style=&quot;color: #808080;&quot;&gt;&amp;#40;&lt;/span&gt;blah1&lt;span style=&quot;color: #808080;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #0000FF;&quot;&gt;GO&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;/div&gt;&lt;div id=&quot;cb73663&quot; style=&quot;display: none; color: red;&quot;&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;Now you can rerun the query to see where all the indexes are.  If you have any non-clustered indexes you&amp;#8217;ll notice that they didn&amp;#8217;t get moved to the secondary filegroup when you moved the table.  GRR! However, this could be a good thing if you want to seperate out the reeds for your non-clustered and clustered indexes.  For my purposes I chose to keep them on the same filegroup.&lt;/p&gt;

&lt;p&gt;To move the stragglers using SSMS right click-properties on the index, go to storage, change the filegroup, and click ok.  This should move the index.&lt;/p&gt;

&lt;p&gt; &lt;img src=&quot;http://blogs.lessthandot.com/media/blogs/DataMgmt/thirster42/FG3.png&quot; alt=&quot;Index Properties&quot; title=&quot;Index Properties&quot; /&gt;&lt;/p&gt;


&lt;p&gt;Behind the scenes SQL Server will just run a create statement, utilizing the DROP_EXISTING command to delete the index if it already exists:&lt;/p&gt;

&lt;div class=&quot;codebox&quot;&gt;&lt;div class=&quot;codeheader&quot;&gt;Code: &lt;span&gt;tsql&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;codeholder&quot;&gt;&lt;div class=&quot;tsql&quot; id=&quot;cb89733&quot; style=&quot;display: block; color: rgb(0, 0, 0);&quot;&gt;&lt;span style=&quot;color: #0000FF;&quot;&gt;CREATE&lt;/span&gt; &lt;span style=&quot;color: #0000FF;&quot;&gt;NONCLUSTERED&lt;/span&gt; &lt;span style=&quot;color: #0000FF;&quot;&gt;INDEX&lt;/span&gt; &lt;span style=&quot;color: #808080;&quot;&gt;&amp;#91;&lt;/span&gt;IDX_Blah&lt;span style=&quot;color: #808080;&quot;&gt;&amp;#93;&lt;/span&gt; &lt;span style=&quot;color: #0000FF;&quot;&gt;ON&lt;/span&gt; &lt;span style=&quot;color: #808080;&quot;&gt;&amp;#91;&lt;/span&gt;dbo&lt;span style=&quot;color: #808080;&quot;&gt;&amp;#93;&lt;/span&gt;.&lt;span style=&quot;color: #808080;&quot;&gt;&amp;#91;&lt;/span&gt;Blah&lt;span style=&quot;color: #808080;&quot;&gt;&amp;#93;&lt;/span&gt; &lt;br /&gt;&lt;span style=&quot;color: #808080;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #808080;&quot;&gt;&amp;#91;&lt;/span&gt;ColA&lt;span style=&quot;color: #808080;&quot;&gt;&amp;#93;&lt;/span&gt; &lt;span style=&quot;color: #0000FF;&quot;&gt;ASC&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #808080;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #0000FF;&quot;&gt;WITH&lt;/span&gt; &lt;span style=&quot;color: #808080;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #0000FF;&quot;&gt;PAD_INDEX&lt;/span&gt; &amp;nbsp;= &lt;span style=&quot;color: #0000FF;&quot;&gt;OFF&lt;/span&gt;, &lt;span style=&quot;color: #0000FF;&quot;&gt;STATISTICS_NORECOMPUTE&lt;/span&gt; &amp;nbsp;= &lt;span style=&quot;color: #0000FF;&quot;&gt;OFF&lt;/span&gt;, &lt;span style=&quot;color: #0000FF;&quot;&gt;SORT_IN_TEMPDB&lt;/span&gt; = &lt;span style=&quot;color: #0000FF;&quot;&gt;OFF&lt;/span&gt;, &lt;span style=&quot;color: #0000FF;&quot;&gt;IGNORE_DUP_KEY&lt;/span&gt; = &lt;span style=&quot;color: #0000FF;&quot;&gt;OFF&lt;/span&gt;, DROP_EXISTING = &lt;span style=&quot;color: #0000FF;&quot;&gt;ON&lt;/span&gt;, &lt;span style=&quot;color: #0000FF;&quot;&gt;ONLINE&lt;/span&gt; = &lt;span style=&quot;color: #0000FF;&quot;&gt;OFF&lt;/span&gt;, &lt;span style=&quot;color: #0000FF;&quot;&gt;ALLOW_ROW_LOCKS&lt;/span&gt; &amp;nbsp;= &lt;span style=&quot;color: #0000FF;&quot;&gt;ON&lt;/span&gt;, &lt;span style=&quot;color: #0000FF;&quot;&gt;ALLOW_PAGE_LOCKS&lt;/span&gt; &amp;nbsp;= &lt;span style=&quot;color: #0000FF;&quot;&gt;ON&lt;/span&gt;, &lt;span style=&quot;color: #0000FF;&quot;&gt;FILLFACTOR&lt;/span&gt; = &lt;span style=&quot;color: #000;&quot;&gt;95&lt;/span&gt;&lt;span style=&quot;color: #808080;&quot;&gt;&amp;#41;&lt;/span&gt; &lt;span style=&quot;color: #0000FF;&quot;&gt;ON&lt;/span&gt; &lt;span style=&quot;color: #808080;&quot;&gt;&amp;#91;&lt;/span&gt;Secondary&lt;span style=&quot;color: #808080;&quot;&gt;&amp;#93;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;/div&gt;&lt;div id=&quot;cb10985&quot; style=&quot;display: none; color: red;&quot;&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;So now you should be able to figure out what filegroups all of your objects are on and be able to move them.  For further reading on filegroups read &lt;a href=&quot;http://blogs.lessthandot.com/index.php/DataMgmt/DBAdmin/sql-server-filegroups-the-what&quot;&gt;SQL Server Filegroups: The What, The Why and The How&lt;br /&gt;
&lt;/a&gt;&lt;/p&gt;&lt;div class=&quot;item_footer&quot;&gt;&lt;p&gt;&lt;small&gt;&lt;a href=&quot;http://blogs.lessthandot.com/index.php/DataMgmt/DataDesign/managing-your-filegroups&quot;&gt;Original post&lt;/a&gt; blogged on &lt;a href=&quot;http://lessthandot.com/&quot;&gt;LessThanDot&lt;/a&gt;.&lt;/small&gt;&lt;/p&gt;&lt;/div&gt;</description>
			<content:encoded><![CDATA[<div><div><a href="http://blogs.lessthandot.com/media/blogs/DataMgmt/thirster42/DatabaseFG.png?mtime=1332444141"><img alt="" src="http://blogs.lessthandot.com/media/blogs/DataMgmt/thirster42/.evocache/DatabaseFG.png/fit-320x320.png?mtime=1332444141" width="248" height="283" /></a></div></div><p>It&#8217;s 4 PM; do you know what's in your filegroups?</p>

<p>I found myself having this inner monologue the other day after I pushed a database form dev to test.  On the dev server I had split the database into two filegroups, one to store the data for the staging tables, and one to store the data for the end results.  The files essentially looked like this:</p>

<p><img src="http://blogs.lessthandot.com/media/blogs/DataMgmt/thirster42/FG1.png" alt="Database Files" title="Database Files" /></p>


<p>I realized that I hadn&#8217;t generated the file groups or extra files on the second server.  I created them and then used this query to find out where the tables and indexes were:</p>


<div class="codebox"><div class="codeheader"><span>tsql</span><div class="codebox_javascript_links"><a href="http://blogs.lessthandot.com" onclick="linenumberOnOff('cb38418'); return false;">Line number Off</a> | <a href="http://blogs.lessthandot.com#" onclick="expandCode('cb38418','cb51334'); return false;">Hide</a> | <a href="http://blogs.lessthandot.com#" onclick="selectCode(this); return false;">Select all</a></div></div><!-- we need this dummy div to fix a firefox bug when selecting code lines --><div class="codeholder"><div class="tsql" id="cb38418" style="display: block; color: rgb(0, 0, 0);"><ol><li style="" class="li1"><span style="color: #0000FF;">select</span> <span style="color: #0000FF;">distinct</span></li><li style="" class="li2">&nbsp; &nbsp; s.<span style="color: #202020;">name</span> <span style="color: #0000FF;">as</span> SchemaName,</li><li style="" class="li1">&nbsp; &nbsp; t.<span style="color: #202020;">name</span> <span style="color: #0000FF;">as</span> TableName,</li><li style="" class="li2">&nbsp; &nbsp; i.<span style="color: #202020;">name</span> <span style="color: #0000FF;">as</span> IndexName,</li><li style="" class="li1">&nbsp; &nbsp; fg.<span style="color: #202020;">name</span> <span style="color: #0000FF;">as</span> FileGroupName</li><li style="" class="li2"><span style="color: #0000FF;">from</span> <span style="color: #00AF00;">sys</span>.<span style="color: #00AF00;">tables</span> t</li><li style="" class="li1">&nbsp; &nbsp; <span style="color: #0000FF;">inner</span> join <span style="color: #00AF00;">sys</span>.<span style="color: #00AF00;">indexes</span> i</li><li style="" class="li2">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0000FF;">on</span> t.<span style="color: #FF00FF;">object_id</span>=i.<span style="color: #FF00FF;">object_id</span></li><li style="" class="li1">&nbsp; &nbsp; <span style="color: #0000FF;">inner</span> join <span style="color: #00AF00;">sys</span>.<span style="color: #00AF00;">schemas</span> s</li><li style="" class="li2">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0000FF;">on</span> t.<span style="color: #FF00FF;">schema_id</span>=s.<span style="color: #FF00FF;">schema_id</span></li><li style="" class="li1">&nbsp; &nbsp; <span style="color: #0000FF;">inner</span> join <span style="color: #00AF00;">sys</span>.<span style="color: #00AF00;">filegroups</span> fg</li><li style="" class="li2">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0000FF;">on</span> i.<span style="color: #202020;">data_space_id</span>=fg.<span style="color: #202020;">data_space_id</span></li><li style="" class="li1"><span style="color: #0000FF;">order</span> <span style="color: #0000FF;">by</span> s.<span style="color: #202020;">name</span>, t.<span style="color: #202020;">name</span>, fg.<span style="color: #202020;">name</span></li></ol></div><div id="cb51334" style="display: none; color: red;"></div></div></div>

<p>In SSMS, as long as you don&#8217;t have a lot of data in the table, the tables (aka the clustered indexes) are easy to move.  Just right click- design on the table and change the filegroup (and text/image filegroup) to secondary and save.  </p>

<p><img src="http://blogs.lessthandot.com/media/blogs/DataMgmt/thirster42/FG2.png" alt="Properties" title="Properties" /><br />
 </p>


<p>Behind the scenes SSMS will create a new table with the same structure on the filegroup, copy the data, drop the old table and rename the new table to the appropriate name.  Now do you see why it matters how much data you have?  If you&#8217;ve got a lot of data then you need to drop the Clustered index, move it, and then recreate the Clustered Index.</p>

<div class="codebox"><div class="codeheader"><span>tsql</span><div class="codebox_javascript_links"><a href="http://blogs.lessthandot.com" onclick="linenumberOnOff('cb9462'); return false;">Line number Off</a> | <a href="http://blogs.lessthandot.com#" onclick="expandCode('cb9462','cb96842'); return false;">Hide</a> | <a href="http://blogs.lessthandot.com#" onclick="selectCode(this); return false;">Select all</a></div></div><!-- we need this dummy div to fix a firefox bug when selecting code lines --><div class="codeholder"><div class="tsql" id="cb9462" style="display: block; color: rgb(0, 0, 0);"><ol><li style="" class="li1"><span style="color: #0000FF;">ALTER</span> <span style="color: #0000FF;">TABLE</span> dbo.<span style="color: #202020;">Blah</span> <span style="color: #0000FF;">DROP</span> <span style="color: #0000FF;">CONSTRAINT</span> PK_Blah <span style="color: #0000FF;">WITH</span> <span style="color: #808080;">&#40;</span><span style="color: #0000FF;">MOVE</span> <span style="color: #0000FF;">TO</span> Secondary<span style="color: #808080;">&#41;</span></li><li style="" class="li2"><span style="color: #0000FF;">GO</span></li><li style="" class="li1"><span style="color: #0000FF;">ALTER</span> <span style="color: #0000FF;">TABLE</span> dbo.<span style="color: #202020;">Blah</span> <span style="color: #0000FF;">ADD</span> <span style="color: #0000FF;">CONSTRAINT</span> PK_Blah <span style="color: #0000FF;">PRIMARY</span> <span style="color: #0000FF;">KEY</span><span style="color: #808080;">&#40;</span>blah1<span style="color: #808080;">&#41;</span></li><li style="" class="li2"><span style="color: #0000FF;">GO</span></li></ol></div><div id="cb96842" style="display: none; color: red;"></div></div></div>

<p>Now you can rerun the query to see where all the indexes are.  If you have any non-clustered indexes you&#8217;ll notice that they didn&#8217;t get moved to the secondary filegroup when you moved the table.  GRR! However, this could be a good thing if you want to seperate out the reeds for your non-clustered and clustered indexes.  For my purposes I chose to keep them on the same filegroup.</p>

<p>To move the stragglers using SSMS right click-properties on the index, go to storage, change the filegroup, and click ok.  This should move the index.</p>

<p> <img src="http://blogs.lessthandot.com/media/blogs/DataMgmt/thirster42/FG3.png" alt="Index Properties" title="Index Properties" /></p>


<p>Behind the scenes SQL Server will just run a create statement, utilizing the DROP_EXISTING command to delete the index if it already exists:</p>

<div class="codebox"><div class="codeheader"><span>tsql</span><div class="codebox_javascript_links"><a href="http://blogs.lessthandot.com" onclick="linenumberOnOff('cb39983'); return false;">Line number Off</a> | <a href="http://blogs.lessthandot.com#" onclick="expandCode('cb39983','cb25698'); return false;">Hide</a> | <a href="http://blogs.lessthandot.com#" onclick="selectCode(this); return false;">Select all</a></div></div><!-- we need this dummy div to fix a firefox bug when selecting code lines --><div class="codeholder"><div class="tsql" id="cb39983" style="display: block; color: rgb(0, 0, 0);"><ol><li style="" class="li1"><span style="color: #0000FF;">CREATE</span> <span style="color: #0000FF;">NONCLUSTERED</span> <span style="color: #0000FF;">INDEX</span> <span style="color: #808080;">&#91;</span>IDX_Blah<span style="color: #808080;">&#93;</span> <span style="color: #0000FF;">ON</span> <span style="color: #808080;">&#91;</span>dbo<span style="color: #808080;">&#93;</span>.<span style="color: #808080;">&#91;</span>Blah<span style="color: #808080;">&#93;</span> </li><li style="" class="li2"><span style="color: #808080;">&#40;</span></li><li style="" class="li1">&nbsp; &nbsp; <span style="color: #808080;">&#91;</span>ColA<span style="color: #808080;">&#93;</span> <span style="color: #0000FF;">ASC</span></li><li style="" class="li2"><span style="color: #808080;">&#41;</span><span style="color: #0000FF;">WITH</span> <span style="color: #808080;">&#40;</span><span style="color: #0000FF;">PAD_INDEX</span> &nbsp;= <span style="color: #0000FF;">OFF</span>, <span style="color: #0000FF;">STATISTICS_NORECOMPUTE</span> &nbsp;= <span style="color: #0000FF;">OFF</span>, <span style="color: #0000FF;">SORT_IN_TEMPDB</span> = <span style="color: #0000FF;">OFF</span>, <span style="color: #0000FF;">IGNORE_DUP_KEY</span> = <span style="color: #0000FF;">OFF</span>, DROP_EXISTING = <span style="color: #0000FF;">ON</span>, <span style="color: #0000FF;">ONLINE</span> = <span style="color: #0000FF;">OFF</span>, <span style="color: #0000FF;">ALLOW_ROW_LOCKS</span> &nbsp;= <span style="color: #0000FF;">ON</span>, <span style="color: #0000FF;">ALLOW_PAGE_LOCKS</span> &nbsp;= <span style="color: #0000FF;">ON</span>, <span style="color: #0000FF;">FILLFACTOR</span> = <span style="color: #000;">95</span><span style="color: #808080;">&#41;</span> <span style="color: #0000FF;">ON</span> <span style="color: #808080;">&#91;</span>Secondary<span style="color: #808080;">&#93;</span></li></ol></div><div id="cb25698" style="display: none; color: red;"></div></div></div>

<p>So now you should be able to figure out what filegroups all of your objects are on and be able to move them.  For further reading on filegroups read <a href="http://blogs.lessthandot.com/index.php/DataMgmt/DBAdmin/sql-server-filegroups-the-what">SQL Server Filegroups: The What, The Why and The How<br />
</a></p><div class="item_footer"><p><small><a href="http://blogs.lessthandot.com/index.php/DataMgmt/DataDesign/managing-your-filegroups">Original post</a> blogged on <a href="http://lessthandot.com/">LessThanDot</a>.</small></p></div>]]></content:encoded>
								<comments>http://blogs.lessthandot.com/index.php/DataMgmt/DataDesign/managing-your-filegroups#comments</comments>
			<wfw:commentRss>http://blogs.lessthandot.com/index.php/DataMgmt/?tempskin=_rss2&#38;disp=comments&#38;p=1674</wfw:commentRss>
		</item>
				<item>
			<title>Setting up Kerberos authentication between SQL Servers</title>
			<link>http://blogs.lessthandot.com/index.php/DataMgmt/DBAdmin/MSSQLServerAdmin/setting-up-kerberos-authentication-between</link>
			<pubDate>Wed, 07 Mar 2012 12:58:00 +0000</pubDate>			<dc:creator>David Forck (thirster42)</dc:creator>
			<category domain="main">Microsoft SQL Server Admin</category>			<guid isPermaLink="false">1652@http://blogs.lessthandot.com/</guid>
						<description>&lt;p&gt;Throughout the last couple of years I&amp;#8217;ve constantly heard that using SA for linked servers is a horrible idea.  Setting up another SQL account with full rights to a server for the link is just about as bad an idea.  If only there was some way to pass the user&amp;#8217;s authentication between servers&amp;#8230;.&lt;/p&gt;

&lt;p&gt;Oh wait, there is!  Thanks to Kerberos authentication we can set up our SQL Servers to pass authentication of a user from one place to another, and now a user will never see anything that they weren&amp;#8217;t supposed to see!&lt;/p&gt;

&lt;p&gt;Here are the steps I followed in order to get this to work for me.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;1. SQL Service Accounts&lt;/strong&gt;&lt;br /&gt;
To do this you need a couple of users to be set up as your service accounts.  Generally you want a separate user for each service so that if one account is compromised/locked out not all of your instances are compromised.  These accounts will need to be set up to log on as a service.  You then go into configuration manager and set the accounts up for the services (this will require the services to restart).&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;2. Set SPN&amp;#8217;s&lt;/strong&gt;&lt;br /&gt;
The service principal name is essentially what tells the servers that they trust each other.  To do this you will need domain admin privileges and to run the following commands for each server.  Also make sure that the service is off when you run these.&lt;/p&gt;

&lt;p&gt;SETSPN &amp;#8211;A MSSQLSvc/[server name].[domain].com [domain]\[service account]&lt;br /&gt;
SETSPN &amp;#8211;A MSSQLSvc/[server name].[domain].com:1433 [domain]\[service account]&lt;/p&gt;


&lt;p&gt;So an example would look like this:&lt;br /&gt;
SETSPN &amp;#8211;A MSSQLSvc/sql1.thirsterdomain.com thirsterdomain\sql1ServiceAccount&lt;br /&gt;
SETSPN &amp;#8211;A MSSQLSvc/sql1.thirsterdomain.com:1433 thirsterdomain\sql1ServiceAccount&lt;/p&gt;


&lt;p&gt;&lt;strong&gt;3. Set up linked servers&lt;/strong&gt;&lt;br /&gt;
The very last thing to do is to set up the linked server on each server.  So if we had SQL1 and SQL2 we&amp;#8217;d run the following commands:&lt;/p&gt;

&lt;div class=&quot;codebox&quot;&gt;&lt;div class=&quot;codeheader&quot;&gt;Code: &lt;span&gt;tsql&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;codeholder&quot;&gt;&lt;div class=&quot;tsql&quot; id=&quot;cb41498&quot; style=&quot;display: block; color: rgb(0, 0, 0);&quot;&gt;&lt;span style=&quot;color: #00AF00;&quot;&gt;--run this on sql2&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #0000FF;&quot;&gt;exec&lt;/span&gt; &lt;span style=&quot;color: #AF0000;&quot;&gt;sp_addlinkedserver&lt;/span&gt; @server=&lt;span style=&quot;color: #FF0000;&quot;&gt;&#039;sql1&#039;&lt;/span&gt;, @srvproduct=&lt;span style=&quot;color: #FF0000;&quot;&gt;&#039;&#039;&lt;/span&gt;, @&lt;span style=&quot;color: #0000FF;&quot;&gt;provider&lt;/span&gt;=&lt;span style=&quot;color: #FF0000;&quot;&gt;&#039;SQLNCLI&#039;&lt;/span&gt;, &amp;nbsp;@provstr=&lt;span style=&quot;color: #FF0000;&quot;&gt;&#039;Integrated Security=SSPI&#039;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #0000FF;&quot;&gt;go&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #0000FF;&quot;&gt;exec&lt;/span&gt; &lt;span style=&quot;color: #AF0000;&quot;&gt;sp_addlinkedsrvlogin&lt;/span&gt; &lt;span style=&quot;color: #FF0000;&quot;&gt;&#039;sql2&#039;&lt;/span&gt;,&lt;span style=&quot;color: #FF0000;&quot;&gt;&#039;true&#039;&lt;/span&gt;&lt;br /&gt;&amp;nbsp;&lt;br /&gt;&lt;span style=&quot;color: #00AF00;&quot;&gt;--run this on sql1&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #0000FF;&quot;&gt;exec&lt;/span&gt; &lt;span style=&quot;color: #AF0000;&quot;&gt;sp_addlinkedserver&lt;/span&gt; @server=&lt;span style=&quot;color: #FF0000;&quot;&gt;&#039;sql2&#039;&lt;/span&gt;, @srvproduct=&lt;span style=&quot;color: #FF0000;&quot;&gt;&#039;&#039;&lt;/span&gt;, @&lt;span style=&quot;color: #0000FF;&quot;&gt;provider&lt;/span&gt;=&lt;span style=&quot;color: #FF0000;&quot;&gt;&#039;SQLNCLI&#039;&lt;/span&gt;, &amp;nbsp;@provstr=&lt;span style=&quot;color: #FF0000;&quot;&gt;&#039;Integrated Security=SSPI&#039;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #0000FF;&quot;&gt;go&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #0000FF;&quot;&gt;exec&lt;/span&gt; &lt;span style=&quot;color: #AF0000;&quot;&gt;sp_addlinkedsrvlogin&lt;/span&gt; &lt;span style=&quot;color: #FF0000;&quot;&gt;&#039;sql2&#039;&lt;/span&gt;,&lt;span style=&quot;color: #FF0000;&quot;&gt;&#039;true&#039;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;/div&gt;&lt;div id=&quot;cb79573&quot; style=&quot;display: none; color: red;&quot;&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;


&lt;p&gt;If you have any questions or any issues with getting this working leave a comment.&lt;/p&gt;&lt;div class=&quot;item_footer&quot;&gt;&lt;p&gt;&lt;small&gt;&lt;a href=&quot;http://blogs.lessthandot.com/index.php/DataMgmt/DBAdmin/MSSQLServerAdmin/setting-up-kerberos-authentication-between&quot;&gt;Original post&lt;/a&gt; blogged on &lt;a href=&quot;http://lessthandot.com/&quot;&gt;LessThanDot&lt;/a&gt;.&lt;/small&gt;&lt;/p&gt;&lt;/div&gt;</description>
			<content:encoded><![CDATA[<p>Throughout the last couple of years I&#8217;ve constantly heard that using SA for linked servers is a horrible idea.  Setting up another SQL account with full rights to a server for the link is just about as bad an idea.  If only there was some way to pass the user&#8217;s authentication between servers&#8230;.</p>

<p>Oh wait, there is!  Thanks to Kerberos authentication we can set up our SQL Servers to pass authentication of a user from one place to another, and now a user will never see anything that they weren&#8217;t supposed to see!</p>

<p>Here are the steps I followed in order to get this to work for me.</p>

<p><strong>1. SQL Service Accounts</strong><br />
To do this you need a couple of users to be set up as your service accounts.  Generally you want a separate user for each service so that if one account is compromised/locked out not all of your instances are compromised.  These accounts will need to be set up to log on as a service.  You then go into configuration manager and set the accounts up for the services (this will require the services to restart).</p>

<p><strong>2. Set SPN&#8217;s</strong><br />
The service principal name is essentially what tells the servers that they trust each other.  To do this you will need domain admin privileges and to run the following commands for each server.  Also make sure that the service is off when you run these.</p>

<p>SETSPN &#8211;A MSSQLSvc/[server name].[domain].com [domain]\[service account]<br />
SETSPN &#8211;A MSSQLSvc/[server name].[domain].com:1433 [domain]\[service account]</p>


<p>So an example would look like this:<br />
SETSPN &#8211;A MSSQLSvc/sql1.thirsterdomain.com thirsterdomain\sql1ServiceAccount<br />
SETSPN &#8211;A MSSQLSvc/sql1.thirsterdomain.com:1433 thirsterdomain\sql1ServiceAccount</p>


<p><strong>3. Set up linked servers</strong><br />
The very last thing to do is to set up the linked server on each server.  So if we had SQL1 and SQL2 we&#8217;d run the following commands:</p>

<div class="codebox"><div class="codeheader"><span>tsql</span><div class="codebox_javascript_links"><a href="http://blogs.lessthandot.com" onclick="linenumberOnOff('cb97586'); return false;">Line number Off</a> | <a href="http://blogs.lessthandot.com#" onclick="expandCode('cb97586','cb79150'); return false;">Hide</a> | <a href="http://blogs.lessthandot.com#" onclick="selectCode(this); return false;">Select all</a></div></div><!-- we need this dummy div to fix a firefox bug when selecting code lines --><div class="codeholder"><div class="tsql" id="cb97586" style="display: block; color: rgb(0, 0, 0);"><ol><li style="" class="li1"><span style="color: #00AF00;">--run this on sql2</span></li><li style="" class="li2"><span style="color: #0000FF;">exec</span> <span style="color: #AF0000;">sp_addlinkedserver</span> @server=<span style="color: #FF0000;">'sql1'</span>, @srvproduct=<span style="color: #FF0000;">''</span>, @<span style="color: #0000FF;">provider</span>=<span style="color: #FF0000;">'SQLNCLI'</span>, &nbsp;@provstr=<span style="color: #FF0000;">'Integrated Security=SSPI'</span></li><li style="" class="li1"><span style="color: #0000FF;">go</span></li><li style="" class="li2"><span style="color: #0000FF;">exec</span> <span style="color: #AF0000;">sp_addlinkedsrvlogin</span> <span style="color: #FF0000;">'sql2'</span>,<span style="color: #FF0000;">'true'</span></li><li style="" class="li1">&nbsp;</li><li style="" class="li2"><span style="color: #00AF00;">--run this on sql1</span></li><li style="" class="li1"><span style="color: #0000FF;">exec</span> <span style="color: #AF0000;">sp_addlinkedserver</span> @server=<span style="color: #FF0000;">'sql2'</span>, @srvproduct=<span style="color: #FF0000;">''</span>, @<span style="color: #0000FF;">provider</span>=<span style="color: #FF0000;">'SQLNCLI'</span>, &nbsp;@provstr=<span style="color: #FF0000;">'Integrated Security=SSPI'</span></li><li style="" class="li2"><span style="color: #0000FF;">go</span></li><li style="" class="li1"><span style="color: #0000FF;">exec</span> <span style="color: #AF0000;">sp_addlinkedsrvlogin</span> <span style="color: #FF0000;">'sql2'</span>,<span style="color: #FF0000;">'true'</span></li></ol></div><div id="cb79150" style="display: none; color: red;"></div></div></div>


<p>If you have any questions or any issues with getting this working leave a comment.</p><div class="item_footer"><p><small><a href="http://blogs.lessthandot.com/index.php/DataMgmt/DBAdmin/MSSQLServerAdmin/setting-up-kerberos-authentication-between">Original post</a> blogged on <a href="http://lessthandot.com/">LessThanDot</a>.</small></p></div>]]></content:encoded>
								<comments>http://blogs.lessthandot.com/index.php/DataMgmt/DBAdmin/MSSQLServerAdmin/setting-up-kerberos-authentication-between#comments</comments>
			<wfw:commentRss>http://blogs.lessthandot.com/index.php/DataMgmt/?tempskin=_rss2&#38;disp=comments&#38;p=1652</wfw:commentRss>
		</item>
				<item>
			<title>Using multi-select parameters?  Then you might need to do this.</title>
			<link>http://blogs.lessthandot.com/index.php/DataMgmt/DataDesign/using-multi-select-parameters-then</link>
			<pubDate>Mon, 20 Feb 2012 12:04:00 +0000</pubDate>			<dc:creator>David Forck (thirster42)</dc:creator>
			<category domain="main">Data Modelling &amp; Design</category>			<guid isPermaLink="false">1630@http://blogs.lessthandot.com/</guid>
						<description>&lt;p&gt;I&amp;#8217;ve created SQL Server Reporting Services reports with Multi-Select parameters before.  In fact it&amp;#8217;s pretty par for the course for me now.  I recently ran into an issue with one of my reports that I had never seen before.  Every so often I&amp;#8217;d get an error stating &amp;#8220;operation cannot run due to current state of the object.&amp;#8221;  Perplexed, I did some searching.  At first I came across this &lt;a href=&quot;http://social.msdn.microsoft.com/Forums/en-US/sqlreportingservices/thread/cb6ede72-6ed1-4379-9d3c-847c11b75b32
&quot;&gt;thread&lt;/a&gt; on msdn.&lt;/p&gt;

&lt;p&gt;Sri vobilisetti basically says to go to c:\program miles\microsoft sql server\msrs10.mssqlserver\reporting services\ReportManager and modify the web config file by adding  &lt;code class=&quot;codespan&quot;&gt;  &amp;lt;add key=&amp;#8221;aspnet:MaxHttpCollectionKeys&amp;#8221; value=&amp;#8221;10000&amp;#8221; /&amp;gt; &lt;/code&gt; to the appsettings section.&lt;/p&gt;

&lt;p&gt;I tried what sri vobilisetti posted, and it fixed my issue.  But I still didn&amp;#8217;t really understand what caused the issue, so I did some digging into what MaxHttpCollectionKeys was.  I eventually found a StackOverflow post that goes into some &lt;a href=&quot;http://stackoverflow.com/questions/8684049/asp-net-ms11-100-how-can-i-change-the-limit-on-the-maximum-number-of-posted-for
&quot;&gt;detail&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;So, from my understanding there was a .Net framework update that limited the number of variables that can be sent via a post in a website.&lt;/p&gt;

&lt;p&gt;So, basically what that means is if you have a report with multi-select parameters, and you select over a certain number of parameters to run your report on, you&amp;#8217;ll get the error &amp;#8220;operation cannot run due to current state of the object&amp;#8221; because you&amp;#8217;ve exceeded the amount of posted data the .Net framework allows.&lt;/p&gt;

&lt;p&gt;Not everyone will experience this issue.  If your multi-select parameters only have a handful of options, you shouldn&#039;t ever run into this issue.  However, if you have parameters that contain a lot of options, then you&#039;ll most likely want to change the default value, otherwise you run the risk of an error getting thrown.&lt;/p&gt;&lt;div class=&quot;item_footer&quot;&gt;&lt;p&gt;&lt;small&gt;&lt;a href=&quot;http://blogs.lessthandot.com/index.php/DataMgmt/DataDesign/using-multi-select-parameters-then&quot;&gt;Original post&lt;/a&gt; blogged on &lt;a href=&quot;http://lessthandot.com/&quot;&gt;LessThanDot&lt;/a&gt;.&lt;/small&gt;&lt;/p&gt;&lt;/div&gt;</description>
			<content:encoded><![CDATA[<p>I&#8217;ve created SQL Server Reporting Services reports with Multi-Select parameters before.  In fact it&#8217;s pretty par for the course for me now.  I recently ran into an issue with one of my reports that I had never seen before.  Every so often I&#8217;d get an error stating &#8220;operation cannot run due to current state of the object.&#8221;  Perplexed, I did some searching.  At first I came across this <a href="http://social.msdn.microsoft.com/Forums/en-US/sqlreportingservices/thread/cb6ede72-6ed1-4379-9d3c-847c11b75b32
">thread</a> on msdn.</p>

<p>Sri vobilisetti basically says to go to c:\program miles\microsoft sql server\msrs10.mssqlserver\reporting services\ReportManager and modify the web config file by adding  <code class="codespan">  &lt;add key=&#8221;aspnet:MaxHttpCollectionKeys&#8221; value=&#8221;10000&#8221; /&gt; </code> to the appsettings section.</p>

<p>I tried what sri vobilisetti posted, and it fixed my issue.  But I still didn&#8217;t really understand what caused the issue, so I did some digging into what MaxHttpCollectionKeys was.  I eventually found a StackOverflow post that goes into some <a href="http://stackoverflow.com/questions/8684049/asp-net-ms11-100-how-can-i-change-the-limit-on-the-maximum-number-of-posted-for
">detail</a>.</p>

<p>So, from my understanding there was a .Net framework update that limited the number of variables that can be sent via a post in a website.</p>

<p>So, basically what that means is if you have a report with multi-select parameters, and you select over a certain number of parameters to run your report on, you&#8217;ll get the error &#8220;operation cannot run due to current state of the object&#8221; because you&#8217;ve exceeded the amount of posted data the .Net framework allows.</p>

<p>Not everyone will experience this issue.  If your multi-select parameters only have a handful of options, you shouldn't ever run into this issue.  However, if you have parameters that contain a lot of options, then you'll most likely want to change the default value, otherwise you run the risk of an error getting thrown.</p><div class="item_footer"><p><small><a href="http://blogs.lessthandot.com/index.php/DataMgmt/DataDesign/using-multi-select-parameters-then">Original post</a> blogged on <a href="http://lessthandot.com/">LessThanDot</a>.</small></p></div>]]></content:encoded>
								<comments>http://blogs.lessthandot.com/index.php/DataMgmt/DataDesign/using-multi-select-parameters-then#comments</comments>
			<wfw:commentRss>http://blogs.lessthandot.com/index.php/DataMgmt/?tempskin=_rss2&#38;disp=comments&#38;p=1630</wfw:commentRss>
		</item>
				<item>
			<title>You should be watching</title>
			<link>http://blogs.lessthandot.com/index.php/DataMgmt/DBAdmin/MSSQLServerAdmin/you-should-be-watching</link>
			<pubDate>Wed, 09 Nov 2011 13:17:00 +0000</pubDate>			<dc:creator>David Forck (thirster42)</dc:creator>
			<category domain="main">Microsoft SQL Server Admin</category>
<category domain="alt">Microsoft SQL Server</category>			<guid isPermaLink="false">1473@http://blogs.lessthandot.com/</guid>
						<description>&lt;p&gt;Have you been watching Brent Ozar PLF&amp;#8217;s Technology Triage Tuesdays?  If you&amp;#8217;re not, you should.  I&amp;#8217;ve been watching for the last couple of months, and every web cast is a golden nugget of information.  However, don&amp;#8217;t feel blue for missing out on this great opportunity because Brent, Jeremiah, Kendra, and Tim record each webcast and post it on their site, &lt;a href=&quot;http://www.brentozar.com/&quot;&gt;BrentOzar.com&lt;/a&gt;.&lt;/p&gt;


&lt;p&gt;Here&amp;#8217;s a few of the ones that I&amp;#8217;ve watched that I&amp;#8217;ve enjoyed and learned a lot:&lt;br /&gt;
&lt;a href=&quot;http://www.brentozar.com/archive/2011/11/theres-something-about-nolock-webcast-video/&quot;&gt;There&#039;s something about nolock&lt;/a&gt;&lt;br /&gt;
&lt;a href=&quot;http://www.brentozar.com/archive/2011/11/how-tell-when-tempdb-problem-webcast-video/&quot;&gt;How to tell when tempdb is a problem&lt;/a&gt;&lt;br /&gt;
&lt;a href=&quot;http://www.brentozar.com/archive/2011/09/how-plan-sql-server-virtualization-project/&quot;&gt;How to plan a sql server virtualization project&lt;/a&gt;&lt;br /&gt;
&lt;a href=&quot;http://www.brentozar.com/archive/2011/09/kendra-little-explains-how-design-smarter-indexes/&quot;&gt;How to design smarter indexes&lt;/a&gt;&lt;/p&gt;



&lt;p&gt;They also have an easy list of free training videos, but they&amp;#8217;re not always as adamant to keep this list up to date with the Tech Triage Tuesday videos.  It can be found here:  &lt;a href=&quot;http://www.brentozar.com/sql-server-training-videos/&quot;&gt;http://www.brentozar.com/sql-server-training-videos/&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Their upcoming web casts can be found here: &lt;a href=&quot;https://brentozarevents.webex.com/mw0306ld/mywebex/default.do?siteurl=brentozarevents&quot;&gt;https://brentozarevents.webex.com/mw0306ld/mywebex/default.do?siteurl=brentozarevents&lt;/a&gt;&lt;/p&gt;&lt;div class=&quot;item_footer&quot;&gt;&lt;p&gt;&lt;small&gt;&lt;a href=&quot;http://blogs.lessthandot.com/index.php/DataMgmt/DBAdmin/MSSQLServerAdmin/you-should-be-watching&quot;&gt;Original post&lt;/a&gt; blogged on &lt;a href=&quot;http://lessthandot.com/&quot;&gt;LessThanDot&lt;/a&gt;.&lt;/small&gt;&lt;/p&gt;&lt;/div&gt;</description>
			<content:encoded><![CDATA[<p>Have you been watching Brent Ozar PLF&#8217;s Technology Triage Tuesdays?  If you&#8217;re not, you should.  I&#8217;ve been watching for the last couple of months, and every web cast is a golden nugget of information.  However, don&#8217;t feel blue for missing out on this great opportunity because Brent, Jeremiah, Kendra, and Tim record each webcast and post it on their site, <a href="http://www.brentozar.com/">BrentOzar.com</a>.</p>


<p>Here&#8217;s a few of the ones that I&#8217;ve watched that I&#8217;ve enjoyed and learned a lot:<br />
<a href="http://www.brentozar.com/archive/2011/11/theres-something-about-nolock-webcast-video/">There's something about nolock</a><br />
<a href="http://www.brentozar.com/archive/2011/11/how-tell-when-tempdb-problem-webcast-video/">How to tell when tempdb is a problem</a><br />
<a href="http://www.brentozar.com/archive/2011/09/how-plan-sql-server-virtualization-project/">How to plan a sql server virtualization project</a><br />
<a href="http://www.brentozar.com/archive/2011/09/kendra-little-explains-how-design-smarter-indexes/">How to design smarter indexes</a></p>



<p>They also have an easy list of free training videos, but they&#8217;re not always as adamant to keep this list up to date with the Tech Triage Tuesday videos.  It can be found here:  <a href="http://www.brentozar.com/sql-server-training-videos/">http://www.brentozar.com/sql-server-training-videos/</a></p>

<p>Their upcoming web casts can be found here: <a href="https://brentozarevents.webex.com/mw0306ld/mywebex/default.do?siteurl=brentozarevents">https://brentozarevents.webex.com/mw0306ld/mywebex/default.do?siteurl=brentozarevents</a></p><div class="item_footer"><p><small><a href="http://blogs.lessthandot.com/index.php/DataMgmt/DBAdmin/MSSQLServerAdmin/you-should-be-watching">Original post</a> blogged on <a href="http://lessthandot.com/">LessThanDot</a>.</small></p></div>]]></content:encoded>
								<comments>http://blogs.lessthandot.com/index.php/DataMgmt/DBAdmin/MSSQLServerAdmin/you-should-be-watching#comments</comments>
			<wfw:commentRss>http://blogs.lessthandot.com/index.php/DataMgmt/?tempskin=_rss2&#38;disp=comments&#38;p=1473</wfw:commentRss>
		</item>
				<item>
			<title>Database space use</title>
			<link>http://blogs.lessthandot.com/index.php/DataMgmt/DBAdmin/MSSQLServerAdmin/database-space-use</link>
			<pubDate>Mon, 24 Oct 2011 18:46:00 +0000</pubDate>			<dc:creator>David Forck (thirster42)</dc:creator>
			<category domain="main">Microsoft SQL Server Admin</category>
<category domain="alt">Microsoft SQL Server</category>			<guid isPermaLink="false">1448@http://blogs.lessthandot.com/</guid>
						<description>&lt;p&gt;I was doing some research on my SQL Servers and wanted to know just how much disk space an instance&#039;s database were taking up.  Since the databases on this instance are across a couple of different arrays and backups and other stuff exist on the server, I figured i&#039;d write some t-sql to figure out this question.  Here&#039;s what I wrote:&lt;/p&gt;



&lt;div class=&quot;codebox&quot;&gt;&lt;div class=&quot;codeheader&quot;&gt;Code: &lt;span&gt;tsql&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;codeholder&quot;&gt;&lt;div class=&quot;tsql&quot; id=&quot;cb87200&quot; style=&quot;display: block; color: rgb(0, 0, 0);&quot;&gt;&lt;span style=&quot;color: #0000FF;&quot;&gt;SELECT&lt;/span&gt; &lt;span style=&quot;color: #FF00FF;&quot;&gt;SUM&lt;/span&gt;&lt;span style=&quot;color: #808080;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #0000FF;&quot;&gt;SIZE&lt;/span&gt;*&lt;span style=&quot;color: #000;&quot;&gt;8&lt;/span&gt;&lt;span style=&quot;color: #808080;&quot;&gt;&amp;#41;&lt;/span&gt;/&lt;span style=&quot;color: #000;&quot;&gt;1024.0&lt;/span&gt;/&lt;span style=&quot;color: #000;&quot;&gt;1024.0&lt;/span&gt; &lt;br /&gt;&lt;span style=&quot;color: #0000FF;&quot;&gt;FROM&lt;/span&gt; master.&lt;span style=&quot;color: #00AF00;&quot;&gt;sys&lt;/span&gt;.&lt;span style=&quot;color: #00AF00;&quot;&gt;sysaltfiles&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;/div&gt;&lt;div id=&quot;cb52050&quot; style=&quot;display: none; color: red;&quot;&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;



&lt;p&gt;That select statement shows me exactly how much space an entire instance (2005+) is taking up (save for any database in any state besides just online).  This isn&#039;t just the size of the data, but rather the space that the database files have taken up.&lt;/p&gt;

&lt;p&gt;One particular use I have for this is determining how much junk is on my server taking up space and gives me a reason to grumble at people.&lt;/p&gt;

&lt;p&gt;So, what&#039;s your biggest instance?  Mine&#039;s currently 268gb.&lt;/p&gt;&lt;div class=&quot;item_footer&quot;&gt;&lt;p&gt;&lt;small&gt;&lt;a href=&quot;http://blogs.lessthandot.com/index.php/DataMgmt/DBAdmin/MSSQLServerAdmin/database-space-use&quot;&gt;Original post&lt;/a&gt; blogged on &lt;a href=&quot;http://lessthandot.com/&quot;&gt;LessThanDot&lt;/a&gt;.&lt;/small&gt;&lt;/p&gt;&lt;/div&gt;</description>
			<content:encoded><![CDATA[<p>I was doing some research on my SQL Servers and wanted to know just how much disk space an instance's database were taking up.  Since the databases on this instance are across a couple of different arrays and backups and other stuff exist on the server, I figured i'd write some t-sql to figure out this question.  Here's what I wrote:</p>



<div class="codebox"><div class="codeheader"><span>tsql</span><div class="codebox_javascript_links"><a href="http://blogs.lessthandot.com" onclick="linenumberOnOff('cb15736'); return false;">Line number Off</a> | <a href="http://blogs.lessthandot.com#" onclick="expandCode('cb15736','cb65902'); return false;">Hide</a> | <a href="http://blogs.lessthandot.com#" onclick="selectCode(this); return false;">Select all</a></div></div><!-- we need this dummy div to fix a firefox bug when selecting code lines --><div class="codeholder"><div class="tsql" id="cb15736" style="display: block; color: rgb(0, 0, 0);"><ol><li style="" class="li1"><span style="color: #0000FF;">SELECT</span> <span style="color: #FF00FF;">SUM</span><span style="color: #808080;">&#40;</span><span style="color: #0000FF;">SIZE</span>*<span style="color: #000;">8</span><span style="color: #808080;">&#41;</span>/<span style="color: #000;">1024.0</span>/<span style="color: #000;">1024.0</span> </li><li style="" class="li2"><span style="color: #0000FF;">FROM</span> master.<span style="color: #00AF00;">sys</span>.<span style="color: #00AF00;">sysaltfiles</span></li></ol></div><div id="cb65902" style="display: none; color: red;"></div></div></div>



<p>That select statement shows me exactly how much space an entire instance (2005+) is taking up (save for any database in any state besides just online).  This isn't just the size of the data, but rather the space that the database files have taken up.</p>

<p>One particular use I have for this is determining how much junk is on my server taking up space and gives me a reason to grumble at people.</p>

<p>So, what's your biggest instance?  Mine's currently 268gb.</p><div class="item_footer"><p><small><a href="http://blogs.lessthandot.com/index.php/DataMgmt/DBAdmin/MSSQLServerAdmin/database-space-use">Original post</a> blogged on <a href="http://lessthandot.com/">LessThanDot</a>.</small></p></div>]]></content:encoded>
								<comments>http://blogs.lessthandot.com/index.php/DataMgmt/DBAdmin/MSSQLServerAdmin/database-space-use#comments</comments>
			<wfw:commentRss>http://blogs.lessthandot.com/index.php/DataMgmt/?tempskin=_rss2&#38;disp=comments&#38;p=1448</wfw:commentRss>
		</item>
				<item>
			<title>Red Gate SQL Toolbelt Review</title>
			<link>http://blogs.lessthandot.com/index.php/DataMgmt/DBAdmin/MSSQLServerAdmin/red-gate-sql-server-database</link>
			<pubDate>Mon, 08 Aug 2011 13:32:00 +0000</pubDate>			<dc:creator>David Forck (thirster42)</dc:creator>
			<category domain="alt">Database Administration</category>
<category domain="main">Microsoft SQL Server Admin</category>
<category domain="alt">Microsoft SQL Server</category>			<guid isPermaLink="false">1379@http://blogs.lessthandot.com/</guid>
						<description>&lt;p&gt;So I&amp;#8217;ve had Redgate&amp;#8217;s &lt;a href=&quot;http://www.red-gate.com/products/sql-development/sql-toolbelt/&quot; target=&quot;_new&quot;&gt;SQL Toolbelt&lt;/a&gt; for about a year now, but up until recently I hadn&amp;#8217;t used most of the tools available to me.  But with the current push we&amp;#8217;re making with trying to straighten out our processes I&amp;#8217;ve been playing with everything to get a feel for how they work and if I want to actually use them.  So far I&amp;#8217;ve been fairly impressed with every piece of software provided by Redgate.  Here&amp;#8217;s my quick review of the SQL Toolbelt&lt;/p&gt;



&lt;p&gt;&lt;strong&gt;SQL Compare&lt;/strong&gt;&lt;br /&gt;
This is the tool that I primarily had my eyes on when I first started asking for the SQL Toolbelt, and I&amp;#8217;ve loved it ever since.  Before we got SQL Compare I was manually creating scripts to copy data down from prod/test, creating backups, then copying and restarting from the backups to push changes to test/prod.  Now I just back up the database, do a sql compare, and run the script that&amp;#8217;s generated.  Out of all of the tools, this is the one that I&amp;#8217;d recommend the most.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;SQL Data Compare&lt;/strong&gt;&lt;br /&gt;
SQL Data Compare has saved me so much time since we&amp;#8217;ve gotten it that it probably pays for the entire license for the SQL Toolbelt in a year.  It allows me to compare the data between two databases on the same server or different servers, script the difference, and then copy and paste the script to the target.  I now no longer have to manually create scripts to copy any data, and I no longer have to move around backups.  This is a must if you prefer updating your test and dev data with what&amp;#8217;s in production.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;SQL Dependency Tracker&lt;/strong&gt;&lt;br /&gt;
SQL Dependency Track is a very interesting tool, and is a life saver on complicated databases, because when you need to make a change to a table you can find exactly which views, sps, etc. will be effected by the update.  A great time saver and a great investment.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;SQL Comparison SDK&lt;/strong&gt;&lt;br /&gt;
Something that I haven&amp;#8217;t played with.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;SQL Packager&lt;/strong&gt;&lt;br /&gt;
Another tool that I haven&amp;#8217;t gotten to play with.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;SQL Prompt&lt;/strong&gt;&lt;br /&gt;
SQL Prompt is the one tool that I&amp;#8217;ve had rounds with.  It sometimes has a mind of its own, but once you get used to it it&amp;#8217;s a great utility to have when you&amp;#8217;re writing new scripts or modifying old ones.  The fact that you can set up your own custom way of formatting sql and then just hit a keystroke to format what&amp;#8217;s on the screen is worth the price of admission (and pain), especially if you&amp;#8217;re working on old code that&amp;#8217;s not formatted at all.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;SQL Doc&lt;/strong&gt;&lt;br /&gt;
SQL Doc is a pretty neat tool.  It allows you to connect to a database and it presents you with all of the objects in the database.  You can then make remarks on different parts of the object, and it then saves those remarks in the database in extended properties.  So what that means is that if you manage to lose your SQL Doc project, all you have to do is reconnect to the database with SQL Doc and voila! You&amp;#8217;ve got all of your documentation back.  The other neat part is that if you use SQL Compare the documentation gets pushed to your test and dev servers (assuming you do your documentation on your dev server first). It&amp;#8217;s a great tool for anyone that has to do any sort of database validation, or just needs to document their database.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;SQL Backup&lt;/strong&gt;&lt;br /&gt;
I have all of my backups scheduled in SQL Server via maintenance plans and jobs. I&amp;#8217;ve got several servers that I&amp;#8217;m backing up.  This tool allows me to add of my servers and track the backups.  The only gripe I&amp;#8217;ve got is that I can&amp;#8217;t zoom out past a couple of days to see the whole week.  Great tool for those managing backups on multiple servers.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;SQL Monitor&lt;/strong&gt;&lt;br /&gt;
I got to play with SQL Monitor for a while with it installed on my local machine, and it was pretty awesome.  I had so much data on my servers that I literally didn&amp;#8217;t know where to start.  I was able to quickly figure everything out though, and it even helped me avert a couple of crisis.  Sadly I haven&amp;#8217;t been able to get licenses to let me monitor every server I have.  I highly recommend this for any DBA, or any dev house that doesn&amp;#8217;t have a dedicated DBA.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;SQL Multi Script&lt;/strong&gt;&lt;br /&gt;
I understand the use of this tool, but I haven&amp;#8217;t really had a need for it, so it&amp;#8217;s gone overlooked for now.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;SQL Data Generator&lt;/strong&gt;&lt;br /&gt;
This is another tool that I haven&amp;#8217;t really had a need to use.  With the databases/applications that we work on we typically have a source of data that&amp;#8217;s going into the database.  I look forward to testing this tool though when the time comes for it.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;SQL Object Level Recovery Native&lt;/strong&gt;&lt;br /&gt;
I haven&amp;#8217;t gotten around to playing with this tool.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;SQL Source Control&lt;/strong&gt;&lt;br /&gt;
I&amp;#8217;ll admit it, I hate having Visual Studios open if I don&amp;#8217;t need to.  I&amp;#8217;ll also admit that I love me a user interface to create a database instead of writing scripts.  Enter SQL Source Control.  It integrates with Management Studios and whatever source control you have set up, so now you can commit changes from Management Studios after you make changes to the database, instead of having to go into VS and update the scripts and then deploy.  A great tool for developers wanting to source control their databases.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;SQL Search&lt;/strong&gt;&lt;br /&gt;
A search engine for you database.  Great for those days when you just can&amp;#8217;t remember the full name of the stored procedure you were working on.&lt;/p&gt;


&lt;p&gt;Overall the SQL Toolbelt from Red Gate is more than worth what Red Gate&amp;#8217;s charging for it, and with every update they push they just get better and better.  I highly recommend it for anyone doing development work in SQL Server, or DBA&amp;#8217;s needing to track development work.&lt;/p&gt;&lt;div class=&quot;item_footer&quot;&gt;&lt;p&gt;&lt;small&gt;&lt;a href=&quot;http://blogs.lessthandot.com/index.php/DataMgmt/DBAdmin/MSSQLServerAdmin/red-gate-sql-server-database&quot;&gt;Original post&lt;/a&gt; blogged on &lt;a href=&quot;http://lessthandot.com/&quot;&gt;LessThanDot&lt;/a&gt;.&lt;/small&gt;&lt;/p&gt;&lt;/div&gt;</description>
			<content:encoded><![CDATA[<p>So I&#8217;ve had Redgate&#8217;s <a href="http://www.red-gate.com/products/sql-development/sql-toolbelt/" target="_new">SQL Toolbelt</a> for about a year now, but up until recently I hadn&#8217;t used most of the tools available to me.  But with the current push we&#8217;re making with trying to straighten out our processes I&#8217;ve been playing with everything to get a feel for how they work and if I want to actually use them.  So far I&#8217;ve been fairly impressed with every piece of software provided by Redgate.  Here&#8217;s my quick review of the SQL Toolbelt</p>



<p><strong>SQL Compare</strong><br />
This is the tool that I primarily had my eyes on when I first started asking for the SQL Toolbelt, and I&#8217;ve loved it ever since.  Before we got SQL Compare I was manually creating scripts to copy data down from prod/test, creating backups, then copying and restarting from the backups to push changes to test/prod.  Now I just back up the database, do a sql compare, and run the script that&#8217;s generated.  Out of all of the tools, this is the one that I&#8217;d recommend the most.</p>

<p><strong>SQL Data Compare</strong><br />
SQL Data Compare has saved me so much time since we&#8217;ve gotten it that it probably pays for the entire license for the SQL Toolbelt in a year.  It allows me to compare the data between two databases on the same server or different servers, script the difference, and then copy and paste the script to the target.  I now no longer have to manually create scripts to copy any data, and I no longer have to move around backups.  This is a must if you prefer updating your test and dev data with what&#8217;s in production.</p>

<p><strong>SQL Dependency Tracker</strong><br />
SQL Dependency Track is a very interesting tool, and is a life saver on complicated databases, because when you need to make a change to a table you can find exactly which views, sps, etc. will be effected by the update.  A great time saver and a great investment.</p>

<p><strong>SQL Comparison SDK</strong><br />
Something that I haven&#8217;t played with.</p>

<p><strong>SQL Packager</strong><br />
Another tool that I haven&#8217;t gotten to play with.</p>

<p><strong>SQL Prompt</strong><br />
SQL Prompt is the one tool that I&#8217;ve had rounds with.  It sometimes has a mind of its own, but once you get used to it it&#8217;s a great utility to have when you&#8217;re writing new scripts or modifying old ones.  The fact that you can set up your own custom way of formatting sql and then just hit a keystroke to format what&#8217;s on the screen is worth the price of admission (and pain), especially if you&#8217;re working on old code that&#8217;s not formatted at all.</p>

<p><strong>SQL Doc</strong><br />
SQL Doc is a pretty neat tool.  It allows you to connect to a database and it presents you with all of the objects in the database.  You can then make remarks on different parts of the object, and it then saves those remarks in the database in extended properties.  So what that means is that if you manage to lose your SQL Doc project, all you have to do is reconnect to the database with SQL Doc and voila! You&#8217;ve got all of your documentation back.  The other neat part is that if you use SQL Compare the documentation gets pushed to your test and dev servers (assuming you do your documentation on your dev server first). It&#8217;s a great tool for anyone that has to do any sort of database validation, or just needs to document their database.</p>

<p><strong>SQL Backup</strong><br />
I have all of my backups scheduled in SQL Server via maintenance plans and jobs. I&#8217;ve got several servers that I&#8217;m backing up.  This tool allows me to add of my servers and track the backups.  The only gripe I&#8217;ve got is that I can&#8217;t zoom out past a couple of days to see the whole week.  Great tool for those managing backups on multiple servers.</p>

<p><strong>SQL Monitor</strong><br />
I got to play with SQL Monitor for a while with it installed on my local machine, and it was pretty awesome.  I had so much data on my servers that I literally didn&#8217;t know where to start.  I was able to quickly figure everything out though, and it even helped me avert a couple of crisis.  Sadly I haven&#8217;t been able to get licenses to let me monitor every server I have.  I highly recommend this for any DBA, or any dev house that doesn&#8217;t have a dedicated DBA.</p>

<p><strong>SQL Multi Script</strong><br />
I understand the use of this tool, but I haven&#8217;t really had a need for it, so it&#8217;s gone overlooked for now.</p>

<p><strong>SQL Data Generator</strong><br />
This is another tool that I haven&#8217;t really had a need to use.  With the databases/applications that we work on we typically have a source of data that&#8217;s going into the database.  I look forward to testing this tool though when the time comes for it.</p>

<p><strong>SQL Object Level Recovery Native</strong><br />
I haven&#8217;t gotten around to playing with this tool.</p>

<p><strong>SQL Source Control</strong><br />
I&#8217;ll admit it, I hate having Visual Studios open if I don&#8217;t need to.  I&#8217;ll also admit that I love me a user interface to create a database instead of writing scripts.  Enter SQL Source Control.  It integrates with Management Studios and whatever source control you have set up, so now you can commit changes from Management Studios after you make changes to the database, instead of having to go into VS and update the scripts and then deploy.  A great tool for developers wanting to source control their databases.</p>

<p><strong>SQL Search</strong><br />
A search engine for you database.  Great for those days when you just can&#8217;t remember the full name of the stored procedure you were working on.</p>


<p>Overall the SQL Toolbelt from Red Gate is more than worth what Red Gate&#8217;s charging for it, and with every update they push they just get better and better.  I highly recommend it for anyone doing development work in SQL Server, or DBA&#8217;s needing to track development work.</p><div class="item_footer"><p><small><a href="http://blogs.lessthandot.com/index.php/DataMgmt/DBAdmin/MSSQLServerAdmin/red-gate-sql-server-database">Original post</a> blogged on <a href="http://lessthandot.com/">LessThanDot</a>.</small></p></div>]]></content:encoded>
								<comments>http://blogs.lessthandot.com/index.php/DataMgmt/DBAdmin/MSSQLServerAdmin/red-gate-sql-server-database#comments</comments>
			<wfw:commentRss>http://blogs.lessthandot.com/index.php/DataMgmt/?tempskin=_rss2&#38;disp=comments&#38;p=1379</wfw:commentRss>
		</item>
				<item>
			<title>Saving Table Space (Quick And Dirty)</title>
			<link>http://blogs.lessthandot.com/index.php/DataMgmt/DBAdmin/MSSQLServerAdmin/saving-table-space-quick-and</link>
			<pubDate>Mon, 13 Jun 2011 21:07:00 +0000</pubDate>			<dc:creator>David Forck (thirster42)</dc:creator>
			<category domain="alt">Data Modelling &amp; Design</category>
<category domain="alt">Database Administration</category>
<category domain="main">Microsoft SQL Server Admin</category>			<guid isPermaLink="false">1303@http://blogs.lessthandot.com/</guid>
						<description>&lt;p&gt;One of the quickest and easiest ways to make a database more performant is to reduce how much space the data takes up.  Here&amp;#8217;s a script that I wrote that&amp;#8217;ll find each table in a database (run it in the context of the database).  This script determines how many rows of data each table has (in kilobytes), determines the size of the data in the table, and then gives you a ratio of data per row.  The higher a data/row ratio the more likely there is a chance of reducing the amount of space   (note that I&amp;#8217;m not looking at table indexes or fill factors, those are another topic to cover).&lt;/p&gt;

&lt;div class=&quot;codebox&quot;&gt;&lt;div class=&quot;codeheader&quot;&gt;Code: &lt;span&gt;tsql&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;codeholder&quot;&gt;&lt;div class=&quot;tsql&quot; id=&quot;cb64413&quot; style=&quot;display: block; color: rgb(0, 0, 0);&quot;&gt;&lt;span style=&quot;color: #0000FF;&quot;&gt;declare&lt;/span&gt; @&lt;span style=&quot;color: #00AF00;&quot;&gt;tables&lt;/span&gt; &lt;span style=&quot;color: #0000FF;&quot;&gt;table&lt;/span&gt; &lt;span style=&quot;color: #808080;&quot;&gt;&amp;#40;&lt;/span&gt;name &lt;span style=&quot;color: #0000FF;&quot;&gt;varchar&lt;/span&gt;&lt;span style=&quot;color: #808080;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #FF00FF;&quot;&gt;max&lt;/span&gt;&lt;span style=&quot;color: #808080;&quot;&gt;&amp;#41;&lt;/span&gt;, ID &lt;span style=&quot;color: #0000FF;&quot;&gt;int&lt;/span&gt; &lt;span style=&quot;color: #0000FF;&quot;&gt;identity&lt;/span&gt;&lt;span style=&quot;color: #808080;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #000;&quot;&gt;1&lt;/span&gt;,&lt;span style=&quot;color: #000;&quot;&gt;1&lt;/span&gt;&lt;span style=&quot;color: #808080;&quot;&gt;&amp;#41;&lt;/span&gt;, cnt &lt;span style=&quot;color: #0000FF;&quot;&gt;int&lt;/span&gt;, &lt;span style=&quot;color: #0000FF;&quot;&gt;size&lt;/span&gt; &lt;span style=&quot;color: #0000FF;&quot;&gt;int&lt;/span&gt;&lt;span style=&quot;color: #808080;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #0000FF;&quot;&gt;declare&lt;/span&gt; @i &lt;span style=&quot;color: #0000FF;&quot;&gt;int&lt;/span&gt;, @&lt;span style=&quot;color: #FF00FF;&quot;&gt;count&lt;/span&gt; &lt;span style=&quot;color: #0000FF;&quot;&gt;int&lt;/span&gt;, @name &lt;span style=&quot;color: #0000FF;&quot;&gt;varchar&lt;/span&gt;&lt;span style=&quot;color: #808080;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #FF00FF;&quot;&gt;max&lt;/span&gt;&lt;span style=&quot;color: #808080;&quot;&gt;&amp;#41;&lt;/span&gt;, @&lt;span style=&quot;color: #0000FF;&quot;&gt;sql&lt;/span&gt; &lt;span style=&quot;color: #0000FF;&quot;&gt;varchar&lt;/span&gt;&lt;span style=&quot;color: #808080;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #FF00FF;&quot;&gt;max&lt;/span&gt;&lt;span style=&quot;color: #808080;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;br /&gt;&amp;nbsp;&lt;br /&gt;&lt;span style=&quot;color: #0000FF;&quot;&gt;insert&lt;/span&gt; &lt;span style=&quot;color: #0000FF;&quot;&gt;into&lt;/span&gt; @&lt;span style=&quot;color: #00AF00;&quot;&gt;tables&lt;/span&gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #808080;&quot;&gt;&amp;#40;&lt;/span&gt;name&lt;span style=&quot;color: #808080;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #0000FF;&quot;&gt;select&lt;/span&gt; &lt;br /&gt;TABLE_SCHEMA + &lt;span style=&quot;color: #FF0000;&quot;&gt;&#039;.&#039;&lt;/span&gt; + TABLE_NAME&lt;br /&gt;&lt;span style=&quot;color: #0000FF;&quot;&gt;from&lt;/span&gt; &lt;span style=&quot;color: #00AF00;&quot;&gt;INFORMATION_SCHEMA&lt;/span&gt;.&lt;span style=&quot;color: #00AF00;&quot;&gt;tables&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #0000FF;&quot;&gt;where&lt;/span&gt; TABLE_TYPE=&lt;span style=&quot;color: #FF0000;&quot;&gt;&#039;base table&#039;&lt;/span&gt;&lt;br /&gt;&amp;nbsp;&lt;br /&gt;&amp;nbsp;&lt;br /&gt;&amp;nbsp;&lt;br /&gt;&lt;span style=&quot;color: #0000FF;&quot;&gt;select&lt;/span&gt; @&lt;span style=&quot;color: #FF00FF;&quot;&gt;count&lt;/span&gt;=&lt;span style=&quot;color: #FF00FF;&quot;&gt;count&lt;/span&gt;&lt;span style=&quot;color: #808080;&quot;&gt;&amp;#40;&lt;/span&gt;*&lt;span style=&quot;color: #808080;&quot;&gt;&amp;#41;&lt;/span&gt; &lt;span style=&quot;color: #0000FF;&quot;&gt;from&lt;/span&gt; @&lt;span style=&quot;color: #00AF00;&quot;&gt;tables&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #0000FF;&quot;&gt;set&lt;/span&gt; @i=&lt;span style=&quot;color: #000;&quot;&gt;1&lt;/span&gt;&lt;br /&gt;&amp;nbsp;&lt;br /&gt;&lt;span style=&quot;color: #0000FF;&quot;&gt;while&lt;/span&gt; @i&amp;lt;=@&lt;span style=&quot;color: #FF00FF;&quot;&gt;count&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #0000FF;&quot;&gt;begin&lt;/span&gt;&lt;br /&gt;&amp;nbsp;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #0000FF;&quot;&gt;create&lt;/span&gt; &lt;span style=&quot;color: #0000FF;&quot;&gt;table&lt;/span&gt; #temp&lt;br /&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #808080;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; name &lt;span style=&quot;color: #0000FF;&quot;&gt;varchar&lt;/span&gt;&lt;span style=&quot;color: #808080;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #FF00FF;&quot;&gt;max&lt;/span&gt;&lt;span style=&quot;color: #808080;&quot;&gt;&amp;#41;&lt;/span&gt;,&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #0000FF;&quot;&gt;rows&lt;/span&gt; &lt;span style=&quot;color: #0000FF;&quot;&gt;varchar&lt;/span&gt;&lt;span style=&quot;color: #808080;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #FF00FF;&quot;&gt;max&lt;/span&gt;&lt;span style=&quot;color: #808080;&quot;&gt;&amp;#41;&lt;/span&gt;,&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; reserved &lt;span style=&quot;color: #0000FF;&quot;&gt;varchar&lt;/span&gt;&lt;span style=&quot;color: #808080;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #FF00FF;&quot;&gt;max&lt;/span&gt;&lt;span style=&quot;color: #808080;&quot;&gt;&amp;#41;&lt;/span&gt;,&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #0000FF;&quot;&gt;data&lt;/span&gt; &lt;span style=&quot;color: #0000FF;&quot;&gt;varchar&lt;/span&gt;&lt;span style=&quot;color: #808080;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #FF00FF;&quot;&gt;max&lt;/span&gt;&lt;span style=&quot;color: #808080;&quot;&gt;&amp;#41;&lt;/span&gt;,&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; index_size &lt;span style=&quot;color: #0000FF;&quot;&gt;varchar&lt;/span&gt;&lt;span style=&quot;color: #808080;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #FF00FF;&quot;&gt;max&lt;/span&gt;&lt;span style=&quot;color: #808080;&quot;&gt;&amp;#41;&lt;/span&gt;,&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; unused &lt;span style=&quot;color: #0000FF;&quot;&gt;varchar&lt;/span&gt;&lt;span style=&quot;color: #808080;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #FF00FF;&quot;&gt;max&lt;/span&gt;&lt;span style=&quot;color: #808080;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #808080;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;br /&gt;&amp;nbsp;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #0000FF;&quot;&gt;select&lt;/span&gt; @name=name &lt;span style=&quot;color: #0000FF;&quot;&gt;from&lt;/span&gt; @&lt;span style=&quot;color: #00AF00;&quot;&gt;tables&lt;/span&gt; &lt;span style=&quot;color: #0000FF;&quot;&gt;where&lt;/span&gt; ID=@i&lt;br /&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #0000FF;&quot;&gt;insert&lt;/span&gt; &lt;span style=&quot;color: #0000FF;&quot;&gt;into&lt;/span&gt; #temp&lt;br /&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #808080;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; name, &lt;span style=&quot;color: #0000FF;&quot;&gt;rows&lt;/span&gt;, reserved, &lt;span style=&quot;color: #0000FF;&quot;&gt;data&lt;/span&gt;, index_size, unused&lt;br /&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #808080;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #0000FF;&quot;&gt;exec&lt;/span&gt; &lt;span style=&quot;color: #AF0000;&quot;&gt;sp_spaceused&lt;/span&gt; @name&lt;br /&gt;&amp;nbsp; &amp;nbsp; &lt;br /&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #0000FF;&quot;&gt;update&lt;/span&gt; @&lt;span style=&quot;color: #00AF00;&quot;&gt;tables&lt;/span&gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #0000FF;&quot;&gt;set&lt;/span&gt; &lt;span style=&quot;color: #0000FF;&quot;&gt;size&lt;/span&gt;=&lt;span style=&quot;color: #FF00FF;&quot;&gt;left&lt;/span&gt;&lt;span style=&quot;color: #808080;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #0000FF;&quot;&gt;data&lt;/span&gt;,&lt;span style=&quot;color: #FF00FF;&quot;&gt;len&lt;/span&gt;&lt;span style=&quot;color: #808080;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #0000FF;&quot;&gt;data&lt;/span&gt;&lt;span style=&quot;color: #808080;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #000;&quot;&gt;-3&lt;/span&gt;&lt;span style=&quot;color: #808080;&quot;&gt;&amp;#41;&lt;/span&gt;,&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; cnt=&lt;span style=&quot;color: #0000FF;&quot;&gt;rows&lt;/span&gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #0000FF;&quot;&gt;from&lt;/span&gt; #temp a&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; cross join @&lt;span style=&quot;color: #00AF00;&quot;&gt;tables&lt;/span&gt; b&lt;br /&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #0000FF;&quot;&gt;where&lt;/span&gt; b.&lt;span style=&quot;color: #202020;&quot;&gt;id&lt;/span&gt;=@i&lt;br /&gt;&amp;nbsp;&lt;br /&gt;&amp;nbsp;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #0000FF;&quot;&gt;drop&lt;/span&gt; &lt;span style=&quot;color: #0000FF;&quot;&gt;table&lt;/span&gt; #temp&lt;br /&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #0000FF;&quot;&gt;set&lt;/span&gt; @i=@i&lt;span style=&quot;color: #000;&quot;&gt;+1&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #0000FF;&quot;&gt;end&lt;/span&gt;&lt;br /&gt;&amp;nbsp;&lt;br /&gt;&amp;nbsp;&lt;br /&gt;&lt;span style=&quot;color: #0000FF;&quot;&gt;select&lt;/span&gt; *,&lt;br /&gt;&lt;span style=&quot;color: #808080;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #0000FF;&quot;&gt;size&lt;/span&gt;*&lt;span style=&quot;color: #000;&quot;&gt;1.0&lt;/span&gt;&lt;span style=&quot;color: #808080;&quot;&gt;&amp;#41;&lt;/span&gt;/cnt &lt;span style=&quot;color: #0000FF;&quot;&gt;as&lt;/span&gt; Ratio&lt;br /&gt;&lt;span style=&quot;color: #0000FF;&quot;&gt;from&lt;/span&gt; @&lt;span style=&quot;color: #00AF00;&quot;&gt;tables&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #0000FF;&quot;&gt;where&lt;/span&gt; cnt&amp;gt;&lt;span style=&quot;color: #000;&quot;&gt;0&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #0000FF;&quot;&gt;order&lt;/span&gt; &lt;span style=&quot;color: #0000FF;&quot;&gt;by&lt;/span&gt; &lt;span style=&quot;color: #808080;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #0000FF;&quot;&gt;size&lt;/span&gt;*&lt;span style=&quot;color: #000;&quot;&gt;1.0&lt;/span&gt;&lt;span style=&quot;color: #808080;&quot;&gt;&amp;#41;&lt;/span&gt;/cnt &lt;span style=&quot;color: #0000FF;&quot;&gt;desc&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;/div&gt;&lt;div id=&quot;cb2005&quot; style=&quot;display: none; color: red;&quot;&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;So after this runs on a database the first row will be the table that has the highest ratio.  Here are some quick ways to reduce your data size:&lt;br /&gt;
&amp;#8226;	Change nvarchar to varchar&lt;br /&gt;
&amp;#8226;	Reduce decimal precision&lt;br /&gt;
&amp;#8226;	Change unnecessary chars to varchars (and update the data to get rid of the extra spacing)&lt;br /&gt;
&amp;#8226;	Change ints to bits (when applicable)&lt;br /&gt;
&amp;#8226;	Change datetimes to dates&lt;br /&gt;
&amp;#8226;	Remove unnecessary columns&lt;br /&gt;
&amp;#8226;	Remove dead rows&lt;br /&gt;
&amp;#8226;       Reduce big int &gt; int &gt; small int &gt; tinyint&lt;/p&gt;


&lt;p&gt;Now I know some people might be thinking that some of these seem like very small changes, but one byte multiplied by 1k is still 1 kb of data.  If you can effectively remove 10 bytes per row (which isn&amp;#8217;t that hard depending on the data types), in a 1k table you can effectively save 10kb of data.  That&amp;#8217;s 10kb less of data that has to be accessed in memory, accessed from the hard drive, sent over the wire, backed up, or possibly stored in index/es, all on just one table!&lt;/p&gt;

&lt;p&gt;Remember to always research your changes and test everything first before pushing changes to a production system; you never know when something might need that extra piece of data.&lt;/p&gt;

&lt;p&gt;One way that you might be interested in modifying the script is by changing the where clause to have a ratio of &gt;=8.  This is signifigant because sql server stores data on 8k pages, and if you&#039;re completely filling, or going over that, you could have additional speed and space issues.  You could also set the count minimum to something like 10 or so to get rid of any small lookup tables you may have.&lt;/p&gt;


&lt;p&gt;For more information on data types and sizes, look &lt;a href=&quot;http://msdn.microsoft.com/en-us/library/ms187752.aspx&quot;&gt;here&lt;/a&gt;&lt;/p&gt;&lt;div class=&quot;item_footer&quot;&gt;&lt;p&gt;&lt;small&gt;&lt;a href=&quot;http://blogs.lessthandot.com/index.php/DataMgmt/DBAdmin/MSSQLServerAdmin/saving-table-space-quick-and&quot;&gt;Original post&lt;/a&gt; blogged on &lt;a href=&quot;http://lessthandot.com/&quot;&gt;LessThanDot&lt;/a&gt;.&lt;/small&gt;&lt;/p&gt;&lt;/div&gt;</description>
			<content:encoded><![CDATA[<p>One of the quickest and easiest ways to make a database more performant is to reduce how much space the data takes up.  Here&#8217;s a script that I wrote that&#8217;ll find each table in a database (run it in the context of the database).  This script determines how many rows of data each table has (in kilobytes), determines the size of the data in the table, and then gives you a ratio of data per row.  The higher a data/row ratio the more likely there is a chance of reducing the amount of space   (note that I&#8217;m not looking at table indexes or fill factors, those are another topic to cover).</p>

<div class="codebox"><div class="codeheader"><span>tsql</span><div class="codebox_javascript_links"><a href="http://blogs.lessthandot.com" onclick="linenumberOnOff('cb17109'); return false;">Line number Off</a> | <a href="http://blogs.lessthandot.com#" onclick="expandCode('cb17109','cb89714'); return false;">Hide</a> | <a href="http://blogs.lessthandot.com#" onclick="selectCode(this); return false;">Select all</a></div></div><!-- we need this dummy div to fix a firefox bug when selecting code lines --><div class="codeholder"><div class="tsql" id="cb17109" style="display: block; color: rgb(0, 0, 0);"><ol><li style="" class="li1"><span style="color: #0000FF;">declare</span> @<span style="color: #00AF00;">tables</span> <span style="color: #0000FF;">table</span> <span style="color: #808080;">&#40;</span>name <span style="color: #0000FF;">varchar</span><span style="color: #808080;">&#40;</span><span style="color: #FF00FF;">max</span><span style="color: #808080;">&#41;</span>, ID <span style="color: #0000FF;">int</span> <span style="color: #0000FF;">identity</span><span style="color: #808080;">&#40;</span><span style="color: #000;">1</span>,<span style="color: #000;">1</span><span style="color: #808080;">&#41;</span>, cnt <span style="color: #0000FF;">int</span>, <span style="color: #0000FF;">size</span> <span style="color: #0000FF;">int</span><span style="color: #808080;">&#41;</span></li><li style="" class="li2"><span style="color: #0000FF;">declare</span> @i <span style="color: #0000FF;">int</span>, @<span style="color: #FF00FF;">count</span> <span style="color: #0000FF;">int</span>, @name <span style="color: #0000FF;">varchar</span><span style="color: #808080;">&#40;</span><span style="color: #FF00FF;">max</span><span style="color: #808080;">&#41;</span>, @<span style="color: #0000FF;">sql</span> <span style="color: #0000FF;">varchar</span><span style="color: #808080;">&#40;</span><span style="color: #FF00FF;">max</span><span style="color: #808080;">&#41;</span></li><li style="" class="li1">&nbsp;</li><li style="" class="li2"><span style="color: #0000FF;">insert</span> <span style="color: #0000FF;">into</span> @<span style="color: #00AF00;">tables</span></li><li style="" class="li1">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #808080;">&#40;</span>name<span style="color: #808080;">&#41;</span></li><li style="" class="li2"><span style="color: #0000FF;">select</span> </li><li style="" class="li1">TABLE_SCHEMA + <span style="color: #FF0000;">'.'</span> + TABLE_NAME</li><li style="" class="li2"><span style="color: #0000FF;">from</span> <span style="color: #00AF00;">INFORMATION_SCHEMA</span>.<span style="color: #00AF00;">tables</span></li><li style="" class="li1"><span style="color: #0000FF;">where</span> TABLE_TYPE=<span style="color: #FF0000;">'base table'</span></li><li style="" class="li2">&nbsp;</li><li style="" class="li1">&nbsp;</li><li style="" class="li2">&nbsp;</li><li style="" class="li1"><span style="color: #0000FF;">select</span> @<span style="color: #FF00FF;">count</span>=<span style="color: #FF00FF;">count</span><span style="color: #808080;">&#40;</span>*<span style="color: #808080;">&#41;</span> <span style="color: #0000FF;">from</span> @<span style="color: #00AF00;">tables</span></li><li style="" class="li2"><span style="color: #0000FF;">set</span> @i=<span style="color: #000;">1</span></li><li style="" class="li1">&nbsp;</li><li style="" class="li2"><span style="color: #0000FF;">while</span> @i&lt;=@<span style="color: #FF00FF;">count</span></li><li style="" class="li1"><span style="color: #0000FF;">begin</span></li><li style="" class="li2">&nbsp;</li><li style="" class="li1">&nbsp; &nbsp; <span style="color: #0000FF;">create</span> <span style="color: #0000FF;">table</span> #temp</li><li style="" class="li2">&nbsp; &nbsp; <span style="color: #808080;">&#40;</span></li><li style="" class="li1">&nbsp; &nbsp; &nbsp; &nbsp; name <span style="color: #0000FF;">varchar</span><span style="color: #808080;">&#40;</span><span style="color: #FF00FF;">max</span><span style="color: #808080;">&#41;</span>,</li><li style="" class="li2">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0000FF;">rows</span> <span style="color: #0000FF;">varchar</span><span style="color: #808080;">&#40;</span><span style="color: #FF00FF;">max</span><span style="color: #808080;">&#41;</span>,</li><li style="" class="li1">&nbsp; &nbsp; &nbsp; &nbsp; reserved <span style="color: #0000FF;">varchar</span><span style="color: #808080;">&#40;</span><span style="color: #FF00FF;">max</span><span style="color: #808080;">&#41;</span>,</li><li style="" class="li2">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0000FF;">data</span> <span style="color: #0000FF;">varchar</span><span style="color: #808080;">&#40;</span><span style="color: #FF00FF;">max</span><span style="color: #808080;">&#41;</span>,</li><li style="" class="li1">&nbsp; &nbsp; &nbsp; &nbsp; index_size <span style="color: #0000FF;">varchar</span><span style="color: #808080;">&#40;</span><span style="color: #FF00FF;">max</span><span style="color: #808080;">&#41;</span>,</li><li style="" class="li2">&nbsp; &nbsp; &nbsp; &nbsp; unused <span style="color: #0000FF;">varchar</span><span style="color: #808080;">&#40;</span><span style="color: #FF00FF;">max</span><span style="color: #808080;">&#41;</span></li><li style="" class="li1">&nbsp; &nbsp; <span style="color: #808080;">&#41;</span></li><li style="" class="li2">&nbsp;</li><li style="" class="li1">&nbsp; &nbsp; <span style="color: #0000FF;">select</span> @name=name <span style="color: #0000FF;">from</span> @<span style="color: #00AF00;">tables</span> <span style="color: #0000FF;">where</span> ID=@i</li><li style="" class="li2">&nbsp; &nbsp; <span style="color: #0000FF;">insert</span> <span style="color: #0000FF;">into</span> #temp</li><li style="" class="li1">&nbsp; &nbsp; <span style="color: #808080;">&#40;</span></li><li style="" class="li2">&nbsp; &nbsp; &nbsp; &nbsp; name, <span style="color: #0000FF;">rows</span>, reserved, <span style="color: #0000FF;">data</span>, index_size, unused</li><li style="" class="li1">&nbsp; &nbsp; <span style="color: #808080;">&#41;</span></li><li style="" class="li2">&nbsp; &nbsp; <span style="color: #0000FF;">exec</span> <span style="color: #AF0000;">sp_spaceused</span> @name</li><li style="" class="li1">&nbsp; &nbsp; </li><li style="" class="li2">&nbsp; &nbsp; <span style="color: #0000FF;">update</span> @<span style="color: #00AF00;">tables</span></li><li style="" class="li1">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0000FF;">set</span> <span style="color: #0000FF;">size</span>=<span style="color: #FF00FF;">left</span><span style="color: #808080;">&#40;</span><span style="color: #0000FF;">data</span>,<span style="color: #FF00FF;">len</span><span style="color: #808080;">&#40;</span><span style="color: #0000FF;">data</span><span style="color: #808080;">&#41;</span><span style="color: #000;">-3</span><span style="color: #808080;">&#41;</span>,</li><li style="" class="li2">&nbsp; &nbsp; &nbsp; &nbsp; cnt=<span style="color: #0000FF;">rows</span></li><li style="" class="li1">&nbsp; &nbsp; <span style="color: #0000FF;">from</span> #temp a</li><li style="" class="li2">&nbsp; &nbsp; &nbsp; &nbsp; cross join @<span style="color: #00AF00;">tables</span> b</li><li style="" class="li1">&nbsp; &nbsp; <span style="color: #0000FF;">where</span> b.<span style="color: #202020;">id</span>=@i</li><li style="" class="li2">&nbsp;</li><li style="" class="li1">&nbsp;</li><li style="" class="li2">&nbsp; &nbsp; <span style="color: #0000FF;">drop</span> <span style="color: #0000FF;">table</span> #temp</li><li style="" class="li1">&nbsp; &nbsp; <span style="color: #0000FF;">set</span> @i=@i<span style="color: #000;">+1</span></li><li style="" class="li2"><span style="color: #0000FF;">end</span></li><li style="" class="li1">&nbsp;</li><li style="" class="li2">&nbsp;</li><li style="" class="li1"><span style="color: #0000FF;">select</span> *,</li><li style="" class="li2"><span style="color: #808080;">&#40;</span><span style="color: #0000FF;">size</span>*<span style="color: #000;">1.0</span><span style="color: #808080;">&#41;</span>/cnt <span style="color: #0000FF;">as</span> Ratio</li><li style="" class="li1"><span style="color: #0000FF;">from</span> @<span style="color: #00AF00;">tables</span></li><li style="" class="li2"><span style="color: #0000FF;">where</span> cnt&gt;<span style="color: #000;">0</span></li><li style="" class="li1"><span style="color: #0000FF;">order</span> <span style="color: #0000FF;">by</span> <span style="color: #808080;">&#40;</span><span style="color: #0000FF;">size</span>*<span style="color: #000;">1.0</span><span style="color: #808080;">&#41;</span>/cnt <span style="color: #0000FF;">desc</span></li></ol></div><div id="cb89714" style="display: none; color: red;"></div></div></div>

<p>So after this runs on a database the first row will be the table that has the highest ratio.  Here are some quick ways to reduce your data size:<br />
&#8226;	Change nvarchar to varchar<br />
&#8226;	Reduce decimal precision<br />
&#8226;	Change unnecessary chars to varchars (and update the data to get rid of the extra spacing)<br />
&#8226;	Change ints to bits (when applicable)<br />
&#8226;	Change datetimes to dates<br />
&#8226;	Remove unnecessary columns<br />
&#8226;	Remove dead rows<br />
&#8226;       Reduce big int > int > small int > tinyint</p>


<p>Now I know some people might be thinking that some of these seem like very small changes, but one byte multiplied by 1k is still 1 kb of data.  If you can effectively remove 10 bytes per row (which isn&#8217;t that hard depending on the data types), in a 1k table you can effectively save 10kb of data.  That&#8217;s 10kb less of data that has to be accessed in memory, accessed from the hard drive, sent over the wire, backed up, or possibly stored in index/es, all on just one table!</p>

<p>Remember to always research your changes and test everything first before pushing changes to a production system; you never know when something might need that extra piece of data.</p>

<p>One way that you might be interested in modifying the script is by changing the where clause to have a ratio of >=8.  This is signifigant because sql server stores data on 8k pages, and if you're completely filling, or going over that, you could have additional speed and space issues.  You could also set the count minimum to something like 10 or so to get rid of any small lookup tables you may have.</p>


<p>For more information on data types and sizes, look <a href="http://msdn.microsoft.com/en-us/library/ms187752.aspx">here</a></p><div class="item_footer"><p><small><a href="http://blogs.lessthandot.com/index.php/DataMgmt/DBAdmin/MSSQLServerAdmin/saving-table-space-quick-and">Original post</a> blogged on <a href="http://lessthandot.com/">LessThanDot</a>.</small></p></div>]]></content:encoded>
								<comments>http://blogs.lessthandot.com/index.php/DataMgmt/DBAdmin/MSSQLServerAdmin/saving-table-space-quick-and#comments</comments>
			<wfw:commentRss>http://blogs.lessthandot.com/index.php/DataMgmt/?tempskin=_rss2&#38;disp=comments&#38;p=1303</wfw:commentRss>
		</item>
			</channel>
</rss>
