<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Wizz's Coding Solutions &#187; SQL</title>
	<atom:link href="http://rainstorms.me.uk/blog/tag/sql/feed/" rel="self" type="application/rss+xml" />
	<link>http://rainstorms.me.uk/blog</link>
	<description>Problems that I come across in day to day coding</description>
	<lastBuildDate>Thu, 07 Jul 2011 07:50:18 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2.1</generator>
		<item>
		<title>Re-attaching SQL Server 2008 databases with Filestreams in a different path</title>
		<link>http://rainstorms.me.uk/blog/2010/07/07/re-attaching-sql-server-2008-databases-with-filestreams-in-a-different-path/</link>
		<comments>http://rainstorms.me.uk/blog/2010/07/07/re-attaching-sql-server-2008-databases-with-filestreams-in-a-different-path/#comments</comments>
		<pubDate>Wed, 07 Jul 2010 15:14:44 +0000</pubDate>
		<dc:creator>wizzard</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[2008]]></category>
		<category><![CDATA[filestream]]></category>
		<category><![CDATA[path]]></category>
		<category><![CDATA[SQL]]></category>
		<category><![CDATA[Transact]]></category>
		<category><![CDATA[Workarounds]]></category>

		<guid isPermaLink="false">http://rainstorms.me.uk/blog/?p=295</guid>
		<description><![CDATA[I&#8217;ve recently been moving servers and when I moved the databases, I was unable to re-attach them with a different path for the filestream folder.  The following blog post has a solution - The Rambling DBA: SQL 2008 Filestream and Attach Database. Bookmark this post No related posts. Related posts brought to you by Yet [...]


No related posts.

Related posts brought to you by <a href='http://yarpp.org'>Yet Another Related Posts Plugin</a>.]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve recently been moving servers and when I moved the databases, I was unable to re-attach them with a different path for the filestream folder.  The following blog post has a solution -</p>
<p><a href="http://jmkehayias.blogspot.com/2008/08/sql-2008-filestream-and-attach-database.html">The Rambling DBA: SQL 2008 Filestream and Attach Database</a>.</p>
<!-- Social Bookmarks BEGIN -->
<div class="social_bookmark">
<a><strong><em>Bookmark this post</em></strong></a>
<br />
<div class="d">
<br />
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://del.icio.us/post?url=http%3A%2F%2Frainstorms.me.uk%2Fblog%2F2010%2F07%2F07%2Fre-attaching-sql-server-2008-databases-with-filestreams-in-a-different-path%2F&amp;title=Re-attaching+SQL+Server+2008+databases+with+Filestreams+in+a+different+path" rel="nofollow" title="Add to&nbsp;Del.icio.us"><img class="social_img" src="http://rainstorms.me.uk/blog/wp-content/plugins/social-bookmarks/images/delicious.png" title="Add to&nbsp;Del.icio.us" alt="Add to&nbsp;Del.icio.us" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://digg.com/submit?phase=2&amp;url=http%3A%2F%2Frainstorms.me.uk%2Fblog%2F2010%2F07%2F07%2Fre-attaching-sql-server-2008-databases-with-filestreams-in-a-different-path%2F&amp;title=Re-attaching+SQL+Server+2008+databases+with+Filestreams+in+a+different+path" rel="nofollow" title="Add to&nbsp;digg"><img class="social_img" src="http://rainstorms.me.uk/blog/wp-content/plugins/social-bookmarks/images/digg.png" title="Add to&nbsp;digg" alt="Add to&nbsp;digg" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.dotnetkicks.com/kick/?url=http%3A%2F%2Frainstorms.me.uk%2Fblog%2F2010%2F07%2F07%2Fre-attaching-sql-server-2008-databases-with-filestreams-in-a-different-path%2F&amp;title=Re-attaching+SQL+Server+2008+databases+with+Filestreams+in+a+different+path" rel="nofollow" title="Add to&nbsp;DotNetKicks"><img class="social_img" src="http://rainstorms.me.uk/blog/wp-content/plugins/social-bookmarks/images/dotnetkicks.png" title="Add to&nbsp;DotNetKicks" alt="Add to&nbsp;DotNetKicks" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.facebook.com/sharer.php?u=http%3A%2F%2Frainstorms.me.uk%2Fblog%2F2010%2F07%2F07%2Fre-attaching-sql-server-2008-databases-with-filestreams-in-a-different-path%2F" rel="nofollow" title="Add to&nbsp;Facebook"><img class="social_img" src="http://rainstorms.me.uk/blog/wp-content/plugins/social-bookmarks/images/facebook.png" title="Add to&nbsp;Facebook" alt="Add to&nbsp;Facebook" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://FriendSite.com/users/bookmarks/?u=http%3A%2F%2Frainstorms.me.uk%2Fblog%2F2010%2F07%2F07%2Fre-attaching-sql-server-2008-databases-with-filestreams-in-a-different-path%2F&amp;t=Re-attaching+SQL+Server+2008+databases+with+Filestreams+in+a+different+path" rel="nofollow" title="Add to&nbsp;FriendSite"><img class="social_img" src="http://rainstorms.me.uk/blog/wp-content/plugins/social-bookmarks/images/friendsite.png" title="Add to&nbsp;FriendSite" alt="Add to&nbsp;FriendSite" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.google.com/bookmarks/mark?op=edit&amp;output=popup&amp;bkmk=http%3A%2F%2Frainstorms.me.uk%2Fblog%2F2010%2F07%2F07%2Fre-attaching-sql-server-2008-databases-with-filestreams-in-a-different-path%2F&amp;title=Re-attaching+SQL+Server+2008+databases+with+Filestreams+in+a+different+path" rel="nofollow" title="Add to&nbsp;Google Bookmarks"><img class="social_img" src="http://rainstorms.me.uk/blog/wp-content/plugins/social-bookmarks/images/google.png" title="Add to&nbsp;Google Bookmarks" alt="Add to&nbsp;Google Bookmarks" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://reddit.com/submit?url=http%3A%2F%2Frainstorms.me.uk%2Fblog%2F2010%2F07%2F07%2Fre-attaching-sql-server-2008-databases-with-filestreams-in-a-different-path%2F&amp;title=Re-attaching+SQL+Server+2008+databases+with+Filestreams+in+a+different+path" rel="nofollow" title="Add to&nbsp;reddit"><img class="social_img" src="http://rainstorms.me.uk/blog/wp-content/plugins/social-bookmarks/images/reddit.png" title="Add to&nbsp;reddit" alt="Add to&nbsp;reddit" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://slashdot.org/bookmark.pl?url=http%3A%2F%2Frainstorms.me.uk%2Fblog%2F2010%2F07%2F07%2Fre-attaching-sql-server-2008-databases-with-filestreams-in-a-different-path%2F&amp;title=Re-attaching+SQL+Server+2008+databases+with+Filestreams+in+a+different+path" rel="nofollow" title="Add to&nbsp;Slashdot"><img class="social_img" src="http://rainstorms.me.uk/blog/wp-content/plugins/social-bookmarks/images/slashdot.png" title="Add to&nbsp;Slashdot" alt="Add to&nbsp;Slashdot" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.stumbleupon.com/submit?url=http%3A%2F%2Frainstorms.me.uk%2Fblog%2F2010%2F07%2F07%2Fre-attaching-sql-server-2008-databases-with-filestreams-in-a-different-path%2F&amp;title=Re-attaching+SQL+Server+2008+databases+with+Filestreams+in+a+different+path" rel="nofollow" title="Add to&nbsp;Stumble Upon"><img class="social_img" src="http://rainstorms.me.uk/blog/wp-content/plugins/social-bookmarks/images/stumbleupon.png" title="Add to&nbsp;Stumble Upon" alt="Add to&nbsp;Stumble Upon" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.shoutwire.com/?p=submit&amp;link=http%3A%2F%2Frainstorms.me.uk%2Fblog%2F2010%2F07%2F07%2Fre-attaching-sql-server-2008-databases-with-filestreams-in-a-different-path%2F" rel="nofollow" title="Add to&nbsp;Shoutwire"><img class="social_img" src="http://rainstorms.me.uk/blog/wp-content/plugins/social-bookmarks/images/shoutwire.png" title="Add to&nbsp;Shoutwire" alt="Add to&nbsp;Shoutwire" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.technorati.com/faves?add=http%3A%2F%2Frainstorms.me.uk%2Fblog%2F2010%2F07%2F07%2Fre-attaching-sql-server-2008-databases-with-filestreams-in-a-different-path%2F" rel="nofollow" title="Add to&nbsp;Technorati"><img class="social_img" src="http://rainstorms.me.uk/blog/wp-content/plugins/social-bookmarks/images/technorati.png" title="Add to&nbsp;Technorati" alt="Add to&nbsp;Technorati" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://myweb2.search.yahoo.com/myresults/bookmarklet?u=http%3A%2F%2Frainstorms.me.uk%2Fblog%2F2010%2F07%2F07%2Fre-attaching-sql-server-2008-databases-with-filestreams-in-a-different-path%2F&amp;t=Re-attaching+SQL+Server+2008+databases+with+Filestreams+in+a+different+path" rel="nofollow" title="Add to&nbsp;Yahoo My Web"><img class="social_img" src="http://rainstorms.me.uk/blog/wp-content/plugins/social-bookmarks/images/yahoo.png" title="Add to&nbsp;Yahoo My Web" alt="Add to&nbsp;Yahoo My Web" /></a>
<br />
</div>
</div>
<!-- Social Bookmarks END -->


<p>No related posts.</p>
<p>Related posts brought to you by <a href='http://yarpp.org'>Yet Another Related Posts Plugin</a>.</p>]]></content:encoded>
			<wfw:commentRss>http://rainstorms.me.uk/blog/2010/07/07/re-attaching-sql-server-2008-databases-with-filestreams-in-a-different-path/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Finding missing foreign keys in Transact SQL (for MS SQL Server)</title>
		<link>http://rainstorms.me.uk/blog/2010/05/25/finding-missing-foreign-keys-in-transact-sql-for-ms-sql-server/</link>
		<comments>http://rainstorms.me.uk/blog/2010/05/25/finding-missing-foreign-keys-in-transact-sql-for-ms-sql-server/#comments</comments>
		<pubDate>Tue, 25 May 2010 15:35:15 +0000</pubDate>
		<dc:creator>wizzard</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[field]]></category>
		<category><![CDATA[foreign key]]></category>
		<category><![CDATA[ID]]></category>
		<category><![CDATA[SQL]]></category>
		<category><![CDATA[SQL Server]]></category>
		<category><![CDATA[Transact SQl]]></category>

		<guid isPermaLink="false">http://rainstorms.me.uk/blog/?p=292</guid>
		<description><![CDATA[When I put together a database, I generally use integer ID fields to reference one table from another and I usually have the referencing field ending in &#8220;ID&#8221;.  e.g if I have Customer and Order tables, Order will have a CustomerID field. The problem is that in a big database, it is easy to forget [...]


No related posts.

Related posts brought to you by <a href='http://yarpp.org'>Yet Another Related Posts Plugin</a>.]]></description>
			<content:encoded><![CDATA[<p>When I put together a database, I generally use integer ID fields to reference one table from another and I usually have the referencing field ending in &#8220;ID&#8221;.  e.g if I have Customer and Order tables, Order will have a CustomerID field.</p>
<p>The problem is that in a big database, it is easy to forget to enforce the foreign key constraints for each and every one, so I thought it would be useful to have a query to find them.  After a bit of playing about, I have ended up with&#8230;</p>
<pre name="code" class="sql">

select table_name,COLUMN_NAME from INFORMATION_SCHEMA.COLUMNS cols where COLUMN_NAME <>'ID' and COLUMN_NAME like '%ID'
and TABLE_NAME not in('dtproperties')
and (select COUNT(*) from INFORMATION_SCHEMA.KEY_COLUMN_USAGE keys where keys.TABLE_NAME=cols.TABLE_NAME and keys.COLUMN_NAME=cols.COLUMN_NAME)=0
order by TABLE_NAME
</pre>
<p>You can add in extra tables to exclude in the &#8220;TABLE_NAME not in&#8221; clause.  I&#8217;ve put dtproperties in there because that is the internal table that was showing up when I didn&#8217;t want it to.</p>
<p>I&#8217;ve tested this in SQL Server 2008, but I suspect that it should be good for anything from SQL 7.0 upwards.</p>
<!-- Social Bookmarks BEGIN -->
<div class="social_bookmark">
<a><strong><em>Bookmark this post</em></strong></a>
<br />
<div class="d">
<br />
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://del.icio.us/post?url=http%3A%2F%2Frainstorms.me.uk%2Fblog%2F2010%2F05%2F25%2Ffinding-missing-foreign-keys-in-transact-sql-for-ms-sql-server%2F&amp;title=Finding+missing+foreign+keys+in+Transact+SQL+%28for+MS+SQL+Server%29" rel="nofollow" title="Add to&nbsp;Del.icio.us"><img class="social_img" src="http://rainstorms.me.uk/blog/wp-content/plugins/social-bookmarks/images/delicious.png" title="Add to&nbsp;Del.icio.us" alt="Add to&nbsp;Del.icio.us" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://digg.com/submit?phase=2&amp;url=http%3A%2F%2Frainstorms.me.uk%2Fblog%2F2010%2F05%2F25%2Ffinding-missing-foreign-keys-in-transact-sql-for-ms-sql-server%2F&amp;title=Finding+missing+foreign+keys+in+Transact+SQL+%28for+MS+SQL+Server%29" rel="nofollow" title="Add to&nbsp;digg"><img class="social_img" src="http://rainstorms.me.uk/blog/wp-content/plugins/social-bookmarks/images/digg.png" title="Add to&nbsp;digg" alt="Add to&nbsp;digg" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.dotnetkicks.com/kick/?url=http%3A%2F%2Frainstorms.me.uk%2Fblog%2F2010%2F05%2F25%2Ffinding-missing-foreign-keys-in-transact-sql-for-ms-sql-server%2F&amp;title=Finding+missing+foreign+keys+in+Transact+SQL+%28for+MS+SQL+Server%29" rel="nofollow" title="Add to&nbsp;DotNetKicks"><img class="social_img" src="http://rainstorms.me.uk/blog/wp-content/plugins/social-bookmarks/images/dotnetkicks.png" title="Add to&nbsp;DotNetKicks" alt="Add to&nbsp;DotNetKicks" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.facebook.com/sharer.php?u=http%3A%2F%2Frainstorms.me.uk%2Fblog%2F2010%2F05%2F25%2Ffinding-missing-foreign-keys-in-transact-sql-for-ms-sql-server%2F" rel="nofollow" title="Add to&nbsp;Facebook"><img class="social_img" src="http://rainstorms.me.uk/blog/wp-content/plugins/social-bookmarks/images/facebook.png" title="Add to&nbsp;Facebook" alt="Add to&nbsp;Facebook" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://FriendSite.com/users/bookmarks/?u=http%3A%2F%2Frainstorms.me.uk%2Fblog%2F2010%2F05%2F25%2Ffinding-missing-foreign-keys-in-transact-sql-for-ms-sql-server%2F&amp;t=Finding+missing+foreign+keys+in+Transact+SQL+%28for+MS+SQL+Server%29" rel="nofollow" title="Add to&nbsp;FriendSite"><img class="social_img" src="http://rainstorms.me.uk/blog/wp-content/plugins/social-bookmarks/images/friendsite.png" title="Add to&nbsp;FriendSite" alt="Add to&nbsp;FriendSite" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.google.com/bookmarks/mark?op=edit&amp;output=popup&amp;bkmk=http%3A%2F%2Frainstorms.me.uk%2Fblog%2F2010%2F05%2F25%2Ffinding-missing-foreign-keys-in-transact-sql-for-ms-sql-server%2F&amp;title=Finding+missing+foreign+keys+in+Transact+SQL+%28for+MS+SQL+Server%29" rel="nofollow" title="Add to&nbsp;Google Bookmarks"><img class="social_img" src="http://rainstorms.me.uk/blog/wp-content/plugins/social-bookmarks/images/google.png" title="Add to&nbsp;Google Bookmarks" alt="Add to&nbsp;Google Bookmarks" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://reddit.com/submit?url=http%3A%2F%2Frainstorms.me.uk%2Fblog%2F2010%2F05%2F25%2Ffinding-missing-foreign-keys-in-transact-sql-for-ms-sql-server%2F&amp;title=Finding+missing+foreign+keys+in+Transact+SQL+%28for+MS+SQL+Server%29" rel="nofollow" title="Add to&nbsp;reddit"><img class="social_img" src="http://rainstorms.me.uk/blog/wp-content/plugins/social-bookmarks/images/reddit.png" title="Add to&nbsp;reddit" alt="Add to&nbsp;reddit" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://slashdot.org/bookmark.pl?url=http%3A%2F%2Frainstorms.me.uk%2Fblog%2F2010%2F05%2F25%2Ffinding-missing-foreign-keys-in-transact-sql-for-ms-sql-server%2F&amp;title=Finding+missing+foreign+keys+in+Transact+SQL+%28for+MS+SQL+Server%29" rel="nofollow" title="Add to&nbsp;Slashdot"><img class="social_img" src="http://rainstorms.me.uk/blog/wp-content/plugins/social-bookmarks/images/slashdot.png" title="Add to&nbsp;Slashdot" alt="Add to&nbsp;Slashdot" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.stumbleupon.com/submit?url=http%3A%2F%2Frainstorms.me.uk%2Fblog%2F2010%2F05%2F25%2Ffinding-missing-foreign-keys-in-transact-sql-for-ms-sql-server%2F&amp;title=Finding+missing+foreign+keys+in+Transact+SQL+%28for+MS+SQL+Server%29" rel="nofollow" title="Add to&nbsp;Stumble Upon"><img class="social_img" src="http://rainstorms.me.uk/blog/wp-content/plugins/social-bookmarks/images/stumbleupon.png" title="Add to&nbsp;Stumble Upon" alt="Add to&nbsp;Stumble Upon" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.shoutwire.com/?p=submit&amp;link=http%3A%2F%2Frainstorms.me.uk%2Fblog%2F2010%2F05%2F25%2Ffinding-missing-foreign-keys-in-transact-sql-for-ms-sql-server%2F" rel="nofollow" title="Add to&nbsp;Shoutwire"><img class="social_img" src="http://rainstorms.me.uk/blog/wp-content/plugins/social-bookmarks/images/shoutwire.png" title="Add to&nbsp;Shoutwire" alt="Add to&nbsp;Shoutwire" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.technorati.com/faves?add=http%3A%2F%2Frainstorms.me.uk%2Fblog%2F2010%2F05%2F25%2Ffinding-missing-foreign-keys-in-transact-sql-for-ms-sql-server%2F" rel="nofollow" title="Add to&nbsp;Technorati"><img class="social_img" src="http://rainstorms.me.uk/blog/wp-content/plugins/social-bookmarks/images/technorati.png" title="Add to&nbsp;Technorati" alt="Add to&nbsp;Technorati" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://myweb2.search.yahoo.com/myresults/bookmarklet?u=http%3A%2F%2Frainstorms.me.uk%2Fblog%2F2010%2F05%2F25%2Ffinding-missing-foreign-keys-in-transact-sql-for-ms-sql-server%2F&amp;t=Finding+missing+foreign+keys+in+Transact+SQL+%28for+MS+SQL+Server%29" rel="nofollow" title="Add to&nbsp;Yahoo My Web"><img class="social_img" src="http://rainstorms.me.uk/blog/wp-content/plugins/social-bookmarks/images/yahoo.png" title="Add to&nbsp;Yahoo My Web" alt="Add to&nbsp;Yahoo My Web" /></a>
<br />
</div>
</div>
<!-- Social Bookmarks END -->


<p>No related posts.</p>
<p>Related posts brought to you by <a href='http://yarpp.org'>Yet Another Related Posts Plugin</a>.</p>]]></content:encoded>
			<wfw:commentRss>http://rainstorms.me.uk/blog/2010/05/25/finding-missing-foreign-keys-in-transact-sql-for-ms-sql-server/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Using sp_change_users_login &#8216;auto_fix&#8217; to fix user/login</title>
		<link>http://rainstorms.me.uk/blog/2010/02/21/using-sp_change_users_login-auto_fix-to-fix-userlogin/</link>
		<comments>http://rainstorms.me.uk/blog/2010/02/21/using-sp_change_users_login-auto_fix-to-fix-userlogin/#comments</comments>
		<pubDate>Sun, 21 Feb 2010 20:27:26 +0000</pubDate>
		<dc:creator>wizzard</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[Changing server]]></category>
		<category><![CDATA[Moving databases]]></category>
		<category><![CDATA[Moving server]]></category>
		<category><![CDATA[SQL]]></category>
		<category><![CDATA[Transact SQl]]></category>
		<category><![CDATA[TSQL]]></category>

		<guid isPermaLink="false">http://rainstorms.me.uk/blog/?p=264</guid>
		<description><![CDATA[I have an occasional problem when moving a database from one server to another that although the users on the database are transferred correctly, the logins on the server are not. This is fair enough, as the logins are associated with the server, and the users are associated with the database. The problem is that [...]


No related posts.

Related posts brought to you by <a href='http://yarpp.org'>Yet Another Related Posts Plugin</a>.]]></description>
			<content:encoded><![CDATA[<p>I have an occasional problem when moving a database from one server to another that although the users on the database are transferred correctly, the logins on the server are not.  This is fair enough, as the logins are associated with the server, and the users are associated with the database.  The problem is that there is no obvious way to re-create the logins correctly as if you try to do it, either the login won&#8217;t map to the old user, or it will complain that it can&#8217;t create a new user because it already exists.</p>
<p>One solution is to simply delete the old users and re-create, but this can be a real pain in the neck, especially if you have complex rights or can&#8217;t delete them because of the way things are configured.  You can get around this with renaming users and re-creating and then switching things over and deleting the old ones, but this is all very tedious.</p>
<p>Fortunately, there is a stored procedure that will deal with the problem.  First of all, create the new login without mapping it to a user.  Once you have done that, open a query window in the appropriate database and run</p>
<p>sp_change_users_login &#8216;auto_fix&#8217;, &#8216;<em>username</em>&#8216;</p>
<p>where <em>username</em> is the username that you want to fix.  It takes a split second to run, so you can do a whole load of them without too much hassle.</p>
<!-- Social Bookmarks BEGIN -->
<div class="social_bookmark">
<a><strong><em>Bookmark this post</em></strong></a>
<br />
<div class="d">
<br />
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://del.icio.us/post?url=http%3A%2F%2Frainstorms.me.uk%2Fblog%2F2010%2F02%2F21%2Fusing-sp_change_users_login-auto_fix-to-fix-userlogin%2F&amp;title=Using+sp_change_users_login+%26%238216%3Bauto_fix%26%238217%3B+to+fix+user%2Flogin" rel="nofollow" title="Add to&nbsp;Del.icio.us"><img class="social_img" src="http://rainstorms.me.uk/blog/wp-content/plugins/social-bookmarks/images/delicious.png" title="Add to&nbsp;Del.icio.us" alt="Add to&nbsp;Del.icio.us" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://digg.com/submit?phase=2&amp;url=http%3A%2F%2Frainstorms.me.uk%2Fblog%2F2010%2F02%2F21%2Fusing-sp_change_users_login-auto_fix-to-fix-userlogin%2F&amp;title=Using+sp_change_users_login+%26%238216%3Bauto_fix%26%238217%3B+to+fix+user%2Flogin" rel="nofollow" title="Add to&nbsp;digg"><img class="social_img" src="http://rainstorms.me.uk/blog/wp-content/plugins/social-bookmarks/images/digg.png" title="Add to&nbsp;digg" alt="Add to&nbsp;digg" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.dotnetkicks.com/kick/?url=http%3A%2F%2Frainstorms.me.uk%2Fblog%2F2010%2F02%2F21%2Fusing-sp_change_users_login-auto_fix-to-fix-userlogin%2F&amp;title=Using+sp_change_users_login+%26%238216%3Bauto_fix%26%238217%3B+to+fix+user%2Flogin" rel="nofollow" title="Add to&nbsp;DotNetKicks"><img class="social_img" src="http://rainstorms.me.uk/blog/wp-content/plugins/social-bookmarks/images/dotnetkicks.png" title="Add to&nbsp;DotNetKicks" alt="Add to&nbsp;DotNetKicks" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.facebook.com/sharer.php?u=http%3A%2F%2Frainstorms.me.uk%2Fblog%2F2010%2F02%2F21%2Fusing-sp_change_users_login-auto_fix-to-fix-userlogin%2F" rel="nofollow" title="Add to&nbsp;Facebook"><img class="social_img" src="http://rainstorms.me.uk/blog/wp-content/plugins/social-bookmarks/images/facebook.png" title="Add to&nbsp;Facebook" alt="Add to&nbsp;Facebook" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://FriendSite.com/users/bookmarks/?u=http%3A%2F%2Frainstorms.me.uk%2Fblog%2F2010%2F02%2F21%2Fusing-sp_change_users_login-auto_fix-to-fix-userlogin%2F&amp;t=Using+sp_change_users_login+%26%238216%3Bauto_fix%26%238217%3B+to+fix+user%2Flogin" rel="nofollow" title="Add to&nbsp;FriendSite"><img class="social_img" src="http://rainstorms.me.uk/blog/wp-content/plugins/social-bookmarks/images/friendsite.png" title="Add to&nbsp;FriendSite" alt="Add to&nbsp;FriendSite" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.google.com/bookmarks/mark?op=edit&amp;output=popup&amp;bkmk=http%3A%2F%2Frainstorms.me.uk%2Fblog%2F2010%2F02%2F21%2Fusing-sp_change_users_login-auto_fix-to-fix-userlogin%2F&amp;title=Using+sp_change_users_login+%26%238216%3Bauto_fix%26%238217%3B+to+fix+user%2Flogin" rel="nofollow" title="Add to&nbsp;Google Bookmarks"><img class="social_img" src="http://rainstorms.me.uk/blog/wp-content/plugins/social-bookmarks/images/google.png" title="Add to&nbsp;Google Bookmarks" alt="Add to&nbsp;Google Bookmarks" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://reddit.com/submit?url=http%3A%2F%2Frainstorms.me.uk%2Fblog%2F2010%2F02%2F21%2Fusing-sp_change_users_login-auto_fix-to-fix-userlogin%2F&amp;title=Using+sp_change_users_login+%26%238216%3Bauto_fix%26%238217%3B+to+fix+user%2Flogin" rel="nofollow" title="Add to&nbsp;reddit"><img class="social_img" src="http://rainstorms.me.uk/blog/wp-content/plugins/social-bookmarks/images/reddit.png" title="Add to&nbsp;reddit" alt="Add to&nbsp;reddit" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://slashdot.org/bookmark.pl?url=http%3A%2F%2Frainstorms.me.uk%2Fblog%2F2010%2F02%2F21%2Fusing-sp_change_users_login-auto_fix-to-fix-userlogin%2F&amp;title=Using+sp_change_users_login+%26%238216%3Bauto_fix%26%238217%3B+to+fix+user%2Flogin" rel="nofollow" title="Add to&nbsp;Slashdot"><img class="social_img" src="http://rainstorms.me.uk/blog/wp-content/plugins/social-bookmarks/images/slashdot.png" title="Add to&nbsp;Slashdot" alt="Add to&nbsp;Slashdot" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.stumbleupon.com/submit?url=http%3A%2F%2Frainstorms.me.uk%2Fblog%2F2010%2F02%2F21%2Fusing-sp_change_users_login-auto_fix-to-fix-userlogin%2F&amp;title=Using+sp_change_users_login+%26%238216%3Bauto_fix%26%238217%3B+to+fix+user%2Flogin" rel="nofollow" title="Add to&nbsp;Stumble Upon"><img class="social_img" src="http://rainstorms.me.uk/blog/wp-content/plugins/social-bookmarks/images/stumbleupon.png" title="Add to&nbsp;Stumble Upon" alt="Add to&nbsp;Stumble Upon" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.shoutwire.com/?p=submit&amp;link=http%3A%2F%2Frainstorms.me.uk%2Fblog%2F2010%2F02%2F21%2Fusing-sp_change_users_login-auto_fix-to-fix-userlogin%2F" rel="nofollow" title="Add to&nbsp;Shoutwire"><img class="social_img" src="http://rainstorms.me.uk/blog/wp-content/plugins/social-bookmarks/images/shoutwire.png" title="Add to&nbsp;Shoutwire" alt="Add to&nbsp;Shoutwire" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.technorati.com/faves?add=http%3A%2F%2Frainstorms.me.uk%2Fblog%2F2010%2F02%2F21%2Fusing-sp_change_users_login-auto_fix-to-fix-userlogin%2F" rel="nofollow" title="Add to&nbsp;Technorati"><img class="social_img" src="http://rainstorms.me.uk/blog/wp-content/plugins/social-bookmarks/images/technorati.png" title="Add to&nbsp;Technorati" alt="Add to&nbsp;Technorati" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://myweb2.search.yahoo.com/myresults/bookmarklet?u=http%3A%2F%2Frainstorms.me.uk%2Fblog%2F2010%2F02%2F21%2Fusing-sp_change_users_login-auto_fix-to-fix-userlogin%2F&amp;t=Using+sp_change_users_login+%26%238216%3Bauto_fix%26%238217%3B+to+fix+user%2Flogin" rel="nofollow" title="Add to&nbsp;Yahoo My Web"><img class="social_img" src="http://rainstorms.me.uk/blog/wp-content/plugins/social-bookmarks/images/yahoo.png" title="Add to&nbsp;Yahoo My Web" alt="Add to&nbsp;Yahoo My Web" /></a>
<br />
</div>
</div>
<!-- Social Bookmarks END -->


<p>No related posts.</p>
<p>Related posts brought to you by <a href='http://yarpp.org'>Yet Another Related Posts Plugin</a>.</p>]]></content:encoded>
			<wfw:commentRss>http://rainstorms.me.uk/blog/2010/02/21/using-sp_change_users_login-auto_fix-to-fix-userlogin/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Locking Records to Prevent Editing in Transact SQL (Microsoft SQL Server)</title>
		<link>http://rainstorms.me.uk/blog/2009/10/06/locking-records-to-prevent-editing-in-transact-sql-microsoft-sql-server/</link>
		<comments>http://rainstorms.me.uk/blog/2009/10/06/locking-records-to-prevent-editing-in-transact-sql-microsoft-sql-server/#comments</comments>
		<pubDate>Tue, 06 Oct 2009 22:50:08 +0000</pubDate>
		<dc:creator>wizzard</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[Lock]]></category>
		<category><![CDATA[Lock Record]]></category>
		<category><![CDATA[Microsoft SQL Server]]></category>
		<category><![CDATA[SQL]]></category>
		<category><![CDATA[SQL Server]]></category>
		<category><![CDATA[Transact]]></category>
		<category><![CDATA[Trigger]]></category>

		<guid isPermaLink="false">http://rainstorms.me.uk/blog/?p=266</guid>
		<description><![CDATA[Sometimes when I&#8217;m writing code, I come up with a solution that I&#8217;m particularly pleased with because it is just so neat.  This is one of those times. I&#8217;ve not been posting much on this blog recently because I&#8217;ve been very absorbed in a big project and been working crazy hours to get the coding [...]


No related posts.

Related posts brought to you by <a href='http://yarpp.org'>Yet Another Related Posts Plugin</a>.]]></description>
			<content:encoded><![CDATA[<p>Sometimes when I&#8217;m writing code, I come up with a solution that I&#8217;m particularly pleased with because it is just so neat.  This is one of those times.
</p>
<p>
I&#8217;ve not been posting much on this blog recently because I&#8217;ve been very absorbed in a big project and been working crazy hours to get the coding done.</p>
<p>
I should explain that this post is not about record locking to prevent concurrent update problems.  This is about being able to put a more permanent lock on a record in order to stop updates being made to it until the lock is removed.</p>
<p>
The project that I&#8217;ve been working on has some shared records in a few tables that are used by a large number of other records in other tables.   The problem is that something was overwriting these shared records, which was pretty disasterous.  I managed to resurrect the data, which wasn&#8217;t such a problem, but I was very worried about how to stop it happening again, since these records are accessed in a number of different places.
</p>
<p>
The obvious first step was to audit the code and check for what was doing it.  I did that and identified some likely suspects and built in some code to prevent it happening again, but I wanted more reassurance than that, so I decided to try to get SQL Server itself to enforce a lock on them.  The solution that I came up with was to use a trigger.
</p>
<p>
The code of the trigger is as follows</p>
<pre name="code" class="sql">
CREATE trigger [dbo].[trgEnforcePersonLock] ON [dbo].[Person]
for UPDATE
AS
BEGIN
	if (select count(*) From deleted WHERE Locked=1)>0 AND (select count(*) From inserted WHERE Locked=1)>0
	begin
		rollback transaction
		raiserror('Cannot modify a locked person!',16,1)
	end 

END
</pre>
<p>The inserted virtual table contains the new data and the deleted virtual table contains the old.  I&#8217;m checking that the update isn&#8217;t unlocking it, because otherwise we&#8217;ll never be able to!  It works by checking whether the record is locked and if so, rolling back the transaction and raising an error.  From testing, it looks like it works pretty well!</p>
<!-- Social Bookmarks BEGIN -->
<div class="social_bookmark">
<a><strong><em>Bookmark this post</em></strong></a>
<br />
<div class="d">
<br />
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://del.icio.us/post?url=http%3A%2F%2Frainstorms.me.uk%2Fblog%2F2009%2F10%2F06%2Flocking-records-to-prevent-editing-in-transact-sql-microsoft-sql-server%2F&amp;title=Locking+Records+to+Prevent+Editing+in+Transact+SQL+%28Microsoft+SQL+Server%29" rel="nofollow" title="Add to&nbsp;Del.icio.us"><img class="social_img" src="http://rainstorms.me.uk/blog/wp-content/plugins/social-bookmarks/images/delicious.png" title="Add to&nbsp;Del.icio.us" alt="Add to&nbsp;Del.icio.us" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://digg.com/submit?phase=2&amp;url=http%3A%2F%2Frainstorms.me.uk%2Fblog%2F2009%2F10%2F06%2Flocking-records-to-prevent-editing-in-transact-sql-microsoft-sql-server%2F&amp;title=Locking+Records+to+Prevent+Editing+in+Transact+SQL+%28Microsoft+SQL+Server%29" rel="nofollow" title="Add to&nbsp;digg"><img class="social_img" src="http://rainstorms.me.uk/blog/wp-content/plugins/social-bookmarks/images/digg.png" title="Add to&nbsp;digg" alt="Add to&nbsp;digg" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.dotnetkicks.com/kick/?url=http%3A%2F%2Frainstorms.me.uk%2Fblog%2F2009%2F10%2F06%2Flocking-records-to-prevent-editing-in-transact-sql-microsoft-sql-server%2F&amp;title=Locking+Records+to+Prevent+Editing+in+Transact+SQL+%28Microsoft+SQL+Server%29" rel="nofollow" title="Add to&nbsp;DotNetKicks"><img class="social_img" src="http://rainstorms.me.uk/blog/wp-content/plugins/social-bookmarks/images/dotnetkicks.png" title="Add to&nbsp;DotNetKicks" alt="Add to&nbsp;DotNetKicks" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.facebook.com/sharer.php?u=http%3A%2F%2Frainstorms.me.uk%2Fblog%2F2009%2F10%2F06%2Flocking-records-to-prevent-editing-in-transact-sql-microsoft-sql-server%2F" rel="nofollow" title="Add to&nbsp;Facebook"><img class="social_img" src="http://rainstorms.me.uk/blog/wp-content/plugins/social-bookmarks/images/facebook.png" title="Add to&nbsp;Facebook" alt="Add to&nbsp;Facebook" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://FriendSite.com/users/bookmarks/?u=http%3A%2F%2Frainstorms.me.uk%2Fblog%2F2009%2F10%2F06%2Flocking-records-to-prevent-editing-in-transact-sql-microsoft-sql-server%2F&amp;t=Locking+Records+to+Prevent+Editing+in+Transact+SQL+%28Microsoft+SQL+Server%29" rel="nofollow" title="Add to&nbsp;FriendSite"><img class="social_img" src="http://rainstorms.me.uk/blog/wp-content/plugins/social-bookmarks/images/friendsite.png" title="Add to&nbsp;FriendSite" alt="Add to&nbsp;FriendSite" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.google.com/bookmarks/mark?op=edit&amp;output=popup&amp;bkmk=http%3A%2F%2Frainstorms.me.uk%2Fblog%2F2009%2F10%2F06%2Flocking-records-to-prevent-editing-in-transact-sql-microsoft-sql-server%2F&amp;title=Locking+Records+to+Prevent+Editing+in+Transact+SQL+%28Microsoft+SQL+Server%29" rel="nofollow" title="Add to&nbsp;Google Bookmarks"><img class="social_img" src="http://rainstorms.me.uk/blog/wp-content/plugins/social-bookmarks/images/google.png" title="Add to&nbsp;Google Bookmarks" alt="Add to&nbsp;Google Bookmarks" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://reddit.com/submit?url=http%3A%2F%2Frainstorms.me.uk%2Fblog%2F2009%2F10%2F06%2Flocking-records-to-prevent-editing-in-transact-sql-microsoft-sql-server%2F&amp;title=Locking+Records+to+Prevent+Editing+in+Transact+SQL+%28Microsoft+SQL+Server%29" rel="nofollow" title="Add to&nbsp;reddit"><img class="social_img" src="http://rainstorms.me.uk/blog/wp-content/plugins/social-bookmarks/images/reddit.png" title="Add to&nbsp;reddit" alt="Add to&nbsp;reddit" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://slashdot.org/bookmark.pl?url=http%3A%2F%2Frainstorms.me.uk%2Fblog%2F2009%2F10%2F06%2Flocking-records-to-prevent-editing-in-transact-sql-microsoft-sql-server%2F&amp;title=Locking+Records+to+Prevent+Editing+in+Transact+SQL+%28Microsoft+SQL+Server%29" rel="nofollow" title="Add to&nbsp;Slashdot"><img class="social_img" src="http://rainstorms.me.uk/blog/wp-content/plugins/social-bookmarks/images/slashdot.png" title="Add to&nbsp;Slashdot" alt="Add to&nbsp;Slashdot" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.stumbleupon.com/submit?url=http%3A%2F%2Frainstorms.me.uk%2Fblog%2F2009%2F10%2F06%2Flocking-records-to-prevent-editing-in-transact-sql-microsoft-sql-server%2F&amp;title=Locking+Records+to+Prevent+Editing+in+Transact+SQL+%28Microsoft+SQL+Server%29" rel="nofollow" title="Add to&nbsp;Stumble Upon"><img class="social_img" src="http://rainstorms.me.uk/blog/wp-content/plugins/social-bookmarks/images/stumbleupon.png" title="Add to&nbsp;Stumble Upon" alt="Add to&nbsp;Stumble Upon" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.shoutwire.com/?p=submit&amp;link=http%3A%2F%2Frainstorms.me.uk%2Fblog%2F2009%2F10%2F06%2Flocking-records-to-prevent-editing-in-transact-sql-microsoft-sql-server%2F" rel="nofollow" title="Add to&nbsp;Shoutwire"><img class="social_img" src="http://rainstorms.me.uk/blog/wp-content/plugins/social-bookmarks/images/shoutwire.png" title="Add to&nbsp;Shoutwire" alt="Add to&nbsp;Shoutwire" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.technorati.com/faves?add=http%3A%2F%2Frainstorms.me.uk%2Fblog%2F2009%2F10%2F06%2Flocking-records-to-prevent-editing-in-transact-sql-microsoft-sql-server%2F" rel="nofollow" title="Add to&nbsp;Technorati"><img class="social_img" src="http://rainstorms.me.uk/blog/wp-content/plugins/social-bookmarks/images/technorati.png" title="Add to&nbsp;Technorati" alt="Add to&nbsp;Technorati" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://myweb2.search.yahoo.com/myresults/bookmarklet?u=http%3A%2F%2Frainstorms.me.uk%2Fblog%2F2009%2F10%2F06%2Flocking-records-to-prevent-editing-in-transact-sql-microsoft-sql-server%2F&amp;t=Locking+Records+to+Prevent+Editing+in+Transact+SQL+%28Microsoft+SQL+Server%29" rel="nofollow" title="Add to&nbsp;Yahoo My Web"><img class="social_img" src="http://rainstorms.me.uk/blog/wp-content/plugins/social-bookmarks/images/yahoo.png" title="Add to&nbsp;Yahoo My Web" alt="Add to&nbsp;Yahoo My Web" /></a>
<br />
</div>
</div>
<!-- Social Bookmarks END -->


<p>No related posts.</p>
<p>Related posts brought to you by <a href='http://yarpp.org'>Yet Another Related Posts Plugin</a>.</p>]]></content:encoded>
			<wfw:commentRss>http://rainstorms.me.uk/blog/2009/10/06/locking-records-to-prevent-editing-in-transact-sql-microsoft-sql-server/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Storing Partial/Incomplete Date/DateTime Values in SQL</title>
		<link>http://rainstorms.me.uk/blog/2009/03/04/storing-partialincomplete-datedatetime-values-in-sql/</link>
		<comments>http://rainstorms.me.uk/blog/2009/03/04/storing-partialincomplete-datedatetime-values-in-sql/#comments</comments>
		<pubDate>Wed, 04 Mar 2009 21:39:01 +0000</pubDate>
		<dc:creator>wizzard</dc:creator>
				<category><![CDATA[Data Storage]]></category>
		<category><![CDATA[Design Patterns]]></category>
		<category><![CDATA[Solutions]]></category>
		<category><![CDATA[SQL]]></category>
		<category><![CDATA[Workarounds]]></category>

		<guid isPermaLink="false">http://rainstorms.me.uk/blog/2009/03/04/storing-partialincomplete-datedatetime-values-in-sql/</guid>
		<description><![CDATA[I am currently working on a project where I am taking data from an old database.  Unfortunately, many of the date fields in the database contain incomplete date values, simply because not all the data was available when it was entered (it was taken off paper, memory and other relatively unreliable storage media). In the [...]


No related posts.

Related posts brought to you by <a href='http://yarpp.org'>Yet Another Related Posts Plugin</a>.]]></description>
			<content:encoded><![CDATA[<p>I am currently working on a project where I am taking data from an old database.  Unfortunately, many of the date fields in the database contain incomplete date values, simply because not all the data was available when it was entered (it was taken off paper, memory and other relatively unreliable storage media).</p>
<p>In the old database, these fields were stored as text.  However, I wanted them to be searchable by date, so I was thinking about it and I have come up with a couple of possible ideas&#8230;</p>
<p>Firstly, you can store the centrepoint datetime and a float to represent a timespan in days of how accurate this is.  Whilst I think it is possible to do an SQL query to query this (I haven&#8217;t actually tried it), it is a bit messy, and I think it would probably be a nightmare to write a Linq to SQL query or use another query framework.</p>
<p>Secondly, you can store the min and max datetime that it could be.  This also allows you to do a little clever parsing when you retrieve the date from the database and for example, you can list a date which is in the database as 2009-01-01 to 2009-01-31 (in ISO date format)  as &#8220;January 2009&#8243;.</p>
<p>Of course, both of these only work if the missing data is the least significant part (in mathematical terms).  I mean, if you know the day and month, but not the year, neither of these schemes work.  For that you&#8217;d probably need to use 3 nullable integer fields, but then searching on that would be a pain.</p>
<!-- Social Bookmarks BEGIN -->
<div class="social_bookmark">
<a><strong><em>Bookmark this post</em></strong></a>
<br />
<div class="d">
<br />
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://del.icio.us/post?url=http%3A%2F%2Frainstorms.me.uk%2Fblog%2F2009%2F03%2F04%2Fstoring-partialincomplete-datedatetime-values-in-sql%2F&amp;title=Storing+Partial%2FIncomplete+Date%2FDateTime+Values+in+SQL" rel="nofollow" title="Add to&nbsp;Del.icio.us"><img class="social_img" src="http://rainstorms.me.uk/blog/wp-content/plugins/social-bookmarks/images/delicious.png" title="Add to&nbsp;Del.icio.us" alt="Add to&nbsp;Del.icio.us" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://digg.com/submit?phase=2&amp;url=http%3A%2F%2Frainstorms.me.uk%2Fblog%2F2009%2F03%2F04%2Fstoring-partialincomplete-datedatetime-values-in-sql%2F&amp;title=Storing+Partial%2FIncomplete+Date%2FDateTime+Values+in+SQL" rel="nofollow" title="Add to&nbsp;digg"><img class="social_img" src="http://rainstorms.me.uk/blog/wp-content/plugins/social-bookmarks/images/digg.png" title="Add to&nbsp;digg" alt="Add to&nbsp;digg" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.dotnetkicks.com/kick/?url=http%3A%2F%2Frainstorms.me.uk%2Fblog%2F2009%2F03%2F04%2Fstoring-partialincomplete-datedatetime-values-in-sql%2F&amp;title=Storing+Partial%2FIncomplete+Date%2FDateTime+Values+in+SQL" rel="nofollow" title="Add to&nbsp;DotNetKicks"><img class="social_img" src="http://rainstorms.me.uk/blog/wp-content/plugins/social-bookmarks/images/dotnetkicks.png" title="Add to&nbsp;DotNetKicks" alt="Add to&nbsp;DotNetKicks" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.facebook.com/sharer.php?u=http%3A%2F%2Frainstorms.me.uk%2Fblog%2F2009%2F03%2F04%2Fstoring-partialincomplete-datedatetime-values-in-sql%2F" rel="nofollow" title="Add to&nbsp;Facebook"><img class="social_img" src="http://rainstorms.me.uk/blog/wp-content/plugins/social-bookmarks/images/facebook.png" title="Add to&nbsp;Facebook" alt="Add to&nbsp;Facebook" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://FriendSite.com/users/bookmarks/?u=http%3A%2F%2Frainstorms.me.uk%2Fblog%2F2009%2F03%2F04%2Fstoring-partialincomplete-datedatetime-values-in-sql%2F&amp;t=Storing+Partial%2FIncomplete+Date%2FDateTime+Values+in+SQL" rel="nofollow" title="Add to&nbsp;FriendSite"><img class="social_img" src="http://rainstorms.me.uk/blog/wp-content/plugins/social-bookmarks/images/friendsite.png" title="Add to&nbsp;FriendSite" alt="Add to&nbsp;FriendSite" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.google.com/bookmarks/mark?op=edit&amp;output=popup&amp;bkmk=http%3A%2F%2Frainstorms.me.uk%2Fblog%2F2009%2F03%2F04%2Fstoring-partialincomplete-datedatetime-values-in-sql%2F&amp;title=Storing+Partial%2FIncomplete+Date%2FDateTime+Values+in+SQL" rel="nofollow" title="Add to&nbsp;Google Bookmarks"><img class="social_img" src="http://rainstorms.me.uk/blog/wp-content/plugins/social-bookmarks/images/google.png" title="Add to&nbsp;Google Bookmarks" alt="Add to&nbsp;Google Bookmarks" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://reddit.com/submit?url=http%3A%2F%2Frainstorms.me.uk%2Fblog%2F2009%2F03%2F04%2Fstoring-partialincomplete-datedatetime-values-in-sql%2F&amp;title=Storing+Partial%2FIncomplete+Date%2FDateTime+Values+in+SQL" rel="nofollow" title="Add to&nbsp;reddit"><img class="social_img" src="http://rainstorms.me.uk/blog/wp-content/plugins/social-bookmarks/images/reddit.png" title="Add to&nbsp;reddit" alt="Add to&nbsp;reddit" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://slashdot.org/bookmark.pl?url=http%3A%2F%2Frainstorms.me.uk%2Fblog%2F2009%2F03%2F04%2Fstoring-partialincomplete-datedatetime-values-in-sql%2F&amp;title=Storing+Partial%2FIncomplete+Date%2FDateTime+Values+in+SQL" rel="nofollow" title="Add to&nbsp;Slashdot"><img class="social_img" src="http://rainstorms.me.uk/blog/wp-content/plugins/social-bookmarks/images/slashdot.png" title="Add to&nbsp;Slashdot" alt="Add to&nbsp;Slashdot" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.stumbleupon.com/submit?url=http%3A%2F%2Frainstorms.me.uk%2Fblog%2F2009%2F03%2F04%2Fstoring-partialincomplete-datedatetime-values-in-sql%2F&amp;title=Storing+Partial%2FIncomplete+Date%2FDateTime+Values+in+SQL" rel="nofollow" title="Add to&nbsp;Stumble Upon"><img class="social_img" src="http://rainstorms.me.uk/blog/wp-content/plugins/social-bookmarks/images/stumbleupon.png" title="Add to&nbsp;Stumble Upon" alt="Add to&nbsp;Stumble Upon" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.shoutwire.com/?p=submit&amp;link=http%3A%2F%2Frainstorms.me.uk%2Fblog%2F2009%2F03%2F04%2Fstoring-partialincomplete-datedatetime-values-in-sql%2F" rel="nofollow" title="Add to&nbsp;Shoutwire"><img class="social_img" src="http://rainstorms.me.uk/blog/wp-content/plugins/social-bookmarks/images/shoutwire.png" title="Add to&nbsp;Shoutwire" alt="Add to&nbsp;Shoutwire" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.technorati.com/faves?add=http%3A%2F%2Frainstorms.me.uk%2Fblog%2F2009%2F03%2F04%2Fstoring-partialincomplete-datedatetime-values-in-sql%2F" rel="nofollow" title="Add to&nbsp;Technorati"><img class="social_img" src="http://rainstorms.me.uk/blog/wp-content/plugins/social-bookmarks/images/technorati.png" title="Add to&nbsp;Technorati" alt="Add to&nbsp;Technorati" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://myweb2.search.yahoo.com/myresults/bookmarklet?u=http%3A%2F%2Frainstorms.me.uk%2Fblog%2F2009%2F03%2F04%2Fstoring-partialincomplete-datedatetime-values-in-sql%2F&amp;t=Storing+Partial%2FIncomplete+Date%2FDateTime+Values+in+SQL" rel="nofollow" title="Add to&nbsp;Yahoo My Web"><img class="social_img" src="http://rainstorms.me.uk/blog/wp-content/plugins/social-bookmarks/images/yahoo.png" title="Add to&nbsp;Yahoo My Web" alt="Add to&nbsp;Yahoo My Web" /></a>
<br />
</div>
</div>
<!-- Social Bookmarks END -->


<p>No related posts.</p>
<p>Related posts brought to you by <a href='http://yarpp.org'>Yet Another Related Posts Plugin</a>.</p>]]></content:encoded>
			<wfw:commentRss>http://rainstorms.me.uk/blog/2009/03/04/storing-partialincomplete-datedatetime-values-in-sql/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Installing SQL Server 2008 Management Studio Express</title>
		<link>http://rainstorms.me.uk/blog/2009/03/04/installing-sql-server-2008-management-studio-express/</link>
		<comments>http://rainstorms.me.uk/blog/2009/03/04/installing-sql-server-2008-management-studio-express/#comments</comments>
		<pubDate>Wed, 04 Mar 2009 10:39:20 +0000</pubDate>
		<dc:creator>wizzard</dc:creator>
				<category><![CDATA[SMSS]]></category>
		<category><![CDATA[SQL]]></category>
		<category><![CDATA[SQL Management Studio]]></category>

		<guid isPermaLink="false">http://rainstorms.me.uk/blog/2009/03/04/installing-sql-server-2008-management-studio-express/</guid>
		<description><![CDATA[I used to use SQL Server 2005 Express and recently upgraded to 2008.  SQL Management Studio 2005 won&#8217;t connect to 2008 &#8211; it gives an error, so I went looking for management studio express 2008, which I couldn&#8217;t find anywhere.  I then tried downloading SQL Server 2008 Express to dig it out from there, which [...]


No related posts.

Related posts brought to you by <a href='http://yarpp.org'>Yet Another Related Posts Plugin</a>.]]></description>
			<content:encoded><![CDATA[<p>I used to use SQL Server 2005 Express and recently upgraded to 2008.  SQL Management Studio 2005 won&#8217;t connect to 2008 &#8211; it gives an error, so I went looking for management studio express 2008, which I couldn&#8217;t find anywhere.  I then tried downloading SQL Server 2008 Express to dig it out from there, which does work, but requires several pre-requisites.  You might want to bear this in mind (and I might have missed something &#8211; let me know if I have)&#8230;
<ol>
<li>Make sure you have .NET Framework 3.5SP1 installed</li>
<li>Make sure you have Windows Installer 4.5 installed</li>
<li>Make sure you have Windows Powershell installed</li>
<li>Uninstall management studio 2005 if you have it installed</li>
<li>Reboot (might not be necessary, but probably sensible)</li>
<li>Download and run SQL Server 2008 Express With Tools</li>
<li>Installation &gt; New SQL Server stand-alone installation or add features to an existing installation</li>
<li>follow through until you get to the features list</li>
<li>Select Management Tools &#8211; Basic</li>
<li>You&#8217;ll probably have to reboot again</li>
</ol>
<p>That should be it.  You should be able to download everything that you need freely from Microsoft&#8217;s site (I usually find it easiest googling it &#8211; Microsoft&#8217;s search engine seems a bit rubbish).</p>
<!-- Social Bookmarks BEGIN -->
<div class="social_bookmark">
<a><strong><em>Bookmark this post</em></strong></a>
<br />
<div class="d">
<br />
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://del.icio.us/post?url=http%3A%2F%2Frainstorms.me.uk%2Fblog%2F2009%2F03%2F04%2Finstalling-sql-server-2008-management-studio-express%2F&amp;title=Installing+SQL+Server+2008+Management+Studio+Express" rel="nofollow" title="Add to&nbsp;Del.icio.us"><img class="social_img" src="http://rainstorms.me.uk/blog/wp-content/plugins/social-bookmarks/images/delicious.png" title="Add to&nbsp;Del.icio.us" alt="Add to&nbsp;Del.icio.us" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://digg.com/submit?phase=2&amp;url=http%3A%2F%2Frainstorms.me.uk%2Fblog%2F2009%2F03%2F04%2Finstalling-sql-server-2008-management-studio-express%2F&amp;title=Installing+SQL+Server+2008+Management+Studio+Express" rel="nofollow" title="Add to&nbsp;digg"><img class="social_img" src="http://rainstorms.me.uk/blog/wp-content/plugins/social-bookmarks/images/digg.png" title="Add to&nbsp;digg" alt="Add to&nbsp;digg" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.dotnetkicks.com/kick/?url=http%3A%2F%2Frainstorms.me.uk%2Fblog%2F2009%2F03%2F04%2Finstalling-sql-server-2008-management-studio-express%2F&amp;title=Installing+SQL+Server+2008+Management+Studio+Express" rel="nofollow" title="Add to&nbsp;DotNetKicks"><img class="social_img" src="http://rainstorms.me.uk/blog/wp-content/plugins/social-bookmarks/images/dotnetkicks.png" title="Add to&nbsp;DotNetKicks" alt="Add to&nbsp;DotNetKicks" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.facebook.com/sharer.php?u=http%3A%2F%2Frainstorms.me.uk%2Fblog%2F2009%2F03%2F04%2Finstalling-sql-server-2008-management-studio-express%2F" rel="nofollow" title="Add to&nbsp;Facebook"><img class="social_img" src="http://rainstorms.me.uk/blog/wp-content/plugins/social-bookmarks/images/facebook.png" title="Add to&nbsp;Facebook" alt="Add to&nbsp;Facebook" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://FriendSite.com/users/bookmarks/?u=http%3A%2F%2Frainstorms.me.uk%2Fblog%2F2009%2F03%2F04%2Finstalling-sql-server-2008-management-studio-express%2F&amp;t=Installing+SQL+Server+2008+Management+Studio+Express" rel="nofollow" title="Add to&nbsp;FriendSite"><img class="social_img" src="http://rainstorms.me.uk/blog/wp-content/plugins/social-bookmarks/images/friendsite.png" title="Add to&nbsp;FriendSite" alt="Add to&nbsp;FriendSite" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.google.com/bookmarks/mark?op=edit&amp;output=popup&amp;bkmk=http%3A%2F%2Frainstorms.me.uk%2Fblog%2F2009%2F03%2F04%2Finstalling-sql-server-2008-management-studio-express%2F&amp;title=Installing+SQL+Server+2008+Management+Studio+Express" rel="nofollow" title="Add to&nbsp;Google Bookmarks"><img class="social_img" src="http://rainstorms.me.uk/blog/wp-content/plugins/social-bookmarks/images/google.png" title="Add to&nbsp;Google Bookmarks" alt="Add to&nbsp;Google Bookmarks" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://reddit.com/submit?url=http%3A%2F%2Frainstorms.me.uk%2Fblog%2F2009%2F03%2F04%2Finstalling-sql-server-2008-management-studio-express%2F&amp;title=Installing+SQL+Server+2008+Management+Studio+Express" rel="nofollow" title="Add to&nbsp;reddit"><img class="social_img" src="http://rainstorms.me.uk/blog/wp-content/plugins/social-bookmarks/images/reddit.png" title="Add to&nbsp;reddit" alt="Add to&nbsp;reddit" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://slashdot.org/bookmark.pl?url=http%3A%2F%2Frainstorms.me.uk%2Fblog%2F2009%2F03%2F04%2Finstalling-sql-server-2008-management-studio-express%2F&amp;title=Installing+SQL+Server+2008+Management+Studio+Express" rel="nofollow" title="Add to&nbsp;Slashdot"><img class="social_img" src="http://rainstorms.me.uk/blog/wp-content/plugins/social-bookmarks/images/slashdot.png" title="Add to&nbsp;Slashdot" alt="Add to&nbsp;Slashdot" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.stumbleupon.com/submit?url=http%3A%2F%2Frainstorms.me.uk%2Fblog%2F2009%2F03%2F04%2Finstalling-sql-server-2008-management-studio-express%2F&amp;title=Installing+SQL+Server+2008+Management+Studio+Express" rel="nofollow" title="Add to&nbsp;Stumble Upon"><img class="social_img" src="http://rainstorms.me.uk/blog/wp-content/plugins/social-bookmarks/images/stumbleupon.png" title="Add to&nbsp;Stumble Upon" alt="Add to&nbsp;Stumble Upon" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.shoutwire.com/?p=submit&amp;link=http%3A%2F%2Frainstorms.me.uk%2Fblog%2F2009%2F03%2F04%2Finstalling-sql-server-2008-management-studio-express%2F" rel="nofollow" title="Add to&nbsp;Shoutwire"><img class="social_img" src="http://rainstorms.me.uk/blog/wp-content/plugins/social-bookmarks/images/shoutwire.png" title="Add to&nbsp;Shoutwire" alt="Add to&nbsp;Shoutwire" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.technorati.com/faves?add=http%3A%2F%2Frainstorms.me.uk%2Fblog%2F2009%2F03%2F04%2Finstalling-sql-server-2008-management-studio-express%2F" rel="nofollow" title="Add to&nbsp;Technorati"><img class="social_img" src="http://rainstorms.me.uk/blog/wp-content/plugins/social-bookmarks/images/technorati.png" title="Add to&nbsp;Technorati" alt="Add to&nbsp;Technorati" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://myweb2.search.yahoo.com/myresults/bookmarklet?u=http%3A%2F%2Frainstorms.me.uk%2Fblog%2F2009%2F03%2F04%2Finstalling-sql-server-2008-management-studio-express%2F&amp;t=Installing+SQL+Server+2008+Management+Studio+Express" rel="nofollow" title="Add to&nbsp;Yahoo My Web"><img class="social_img" src="http://rainstorms.me.uk/blog/wp-content/plugins/social-bookmarks/images/yahoo.png" title="Add to&nbsp;Yahoo My Web" alt="Add to&nbsp;Yahoo My Web" /></a>
<br />
</div>
</div>
<!-- Social Bookmarks END -->


<p>No related posts.</p>
<p>Related posts brought to you by <a href='http://yarpp.org'>Yet Another Related Posts Plugin</a>.</p>]]></content:encoded>
			<wfw:commentRss>http://rainstorms.me.uk/blog/2009/03/04/installing-sql-server-2008-management-studio-express/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>SQL Server Express Edition</title>
		<link>http://rainstorms.me.uk/blog/2008/03/18/sql-server-express-edition/</link>
		<comments>http://rainstorms.me.uk/blog/2008/03/18/sql-server-express-edition/#comments</comments>
		<pubDate>Tue, 18 Mar 2008 00:06:59 +0000</pubDate>
		<dc:creator>wizzard</dc:creator>
				<category><![CDATA[Solutions]]></category>
		<category><![CDATA[SQL]]></category>

		<guid isPermaLink="false">http://rainstorms.me.uk/blog/2008/03/18/sql-server-express-edition/</guid>
		<description><![CDATA[SQL Server Express Edition is the free version of Microsoft SQL Server, and is a replacement for MSDE.  It has almost all the features of the other versions of SQL Server.  There is a common misconception that it is limited in terms of the number of connections it can accept.  I am pretty sure this [...]


No related posts.

Related posts brought to you by <a href='http://yarpp.org'>Yet Another Related Posts Plugin</a>.]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.microsoft.com/sql/editions/express/default.mspx">SQL Server Express Edition</a> is the free version of Microsoft SQL Server, and is a replacement for MSDE.  It has almost all the features of the other versions of SQL Server.  There is a common misconception that it is limited in terms of the number of connections it can accept.  I am pretty sure this is something that people think because it used to be true of MSDE.  It does have some limitations, however, including : -</p>
<ul>
<li>Only supports 1 CPU (although it won&#8217;t break if you put it on a multicore/multiprocessor system)</li>
<li>Won&#8217;t use more than 1GB RAM</li>
<li>Databases can&#8217;t grow to more than 4GB</li>
</ul>
<p>This is fine for most jobs, but obviously if you have a really busy or big system then you&#8217;ll need to go for a higher edition or another alternative.</p>
<!-- Social Bookmarks BEGIN -->
<div class="social_bookmark">
<a><strong><em>Bookmark this post</em></strong></a>
<br />
<div class="d">
<br />
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://del.icio.us/post?url=http%3A%2F%2Frainstorms.me.uk%2Fblog%2F2008%2F03%2F18%2Fsql-server-express-edition%2F&amp;title=SQL+Server+Express+Edition" rel="nofollow" title="Add to&nbsp;Del.icio.us"><img class="social_img" src="http://rainstorms.me.uk/blog/wp-content/plugins/social-bookmarks/images/delicious.png" title="Add to&nbsp;Del.icio.us" alt="Add to&nbsp;Del.icio.us" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://digg.com/submit?phase=2&amp;url=http%3A%2F%2Frainstorms.me.uk%2Fblog%2F2008%2F03%2F18%2Fsql-server-express-edition%2F&amp;title=SQL+Server+Express+Edition" rel="nofollow" title="Add to&nbsp;digg"><img class="social_img" src="http://rainstorms.me.uk/blog/wp-content/plugins/social-bookmarks/images/digg.png" title="Add to&nbsp;digg" alt="Add to&nbsp;digg" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.dotnetkicks.com/kick/?url=http%3A%2F%2Frainstorms.me.uk%2Fblog%2F2008%2F03%2F18%2Fsql-server-express-edition%2F&amp;title=SQL+Server+Express+Edition" rel="nofollow" title="Add to&nbsp;DotNetKicks"><img class="social_img" src="http://rainstorms.me.uk/blog/wp-content/plugins/social-bookmarks/images/dotnetkicks.png" title="Add to&nbsp;DotNetKicks" alt="Add to&nbsp;DotNetKicks" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.facebook.com/sharer.php?u=http%3A%2F%2Frainstorms.me.uk%2Fblog%2F2008%2F03%2F18%2Fsql-server-express-edition%2F" rel="nofollow" title="Add to&nbsp;Facebook"><img class="social_img" src="http://rainstorms.me.uk/blog/wp-content/plugins/social-bookmarks/images/facebook.png" title="Add to&nbsp;Facebook" alt="Add to&nbsp;Facebook" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://FriendSite.com/users/bookmarks/?u=http%3A%2F%2Frainstorms.me.uk%2Fblog%2F2008%2F03%2F18%2Fsql-server-express-edition%2F&amp;t=SQL+Server+Express+Edition" rel="nofollow" title="Add to&nbsp;FriendSite"><img class="social_img" src="http://rainstorms.me.uk/blog/wp-content/plugins/social-bookmarks/images/friendsite.png" title="Add to&nbsp;FriendSite" alt="Add to&nbsp;FriendSite" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.google.com/bookmarks/mark?op=edit&amp;output=popup&amp;bkmk=http%3A%2F%2Frainstorms.me.uk%2Fblog%2F2008%2F03%2F18%2Fsql-server-express-edition%2F&amp;title=SQL+Server+Express+Edition" rel="nofollow" title="Add to&nbsp;Google Bookmarks"><img class="social_img" src="http://rainstorms.me.uk/blog/wp-content/plugins/social-bookmarks/images/google.png" title="Add to&nbsp;Google Bookmarks" alt="Add to&nbsp;Google Bookmarks" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://reddit.com/submit?url=http%3A%2F%2Frainstorms.me.uk%2Fblog%2F2008%2F03%2F18%2Fsql-server-express-edition%2F&amp;title=SQL+Server+Express+Edition" rel="nofollow" title="Add to&nbsp;reddit"><img class="social_img" src="http://rainstorms.me.uk/blog/wp-content/plugins/social-bookmarks/images/reddit.png" title="Add to&nbsp;reddit" alt="Add to&nbsp;reddit" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://slashdot.org/bookmark.pl?url=http%3A%2F%2Frainstorms.me.uk%2Fblog%2F2008%2F03%2F18%2Fsql-server-express-edition%2F&amp;title=SQL+Server+Express+Edition" rel="nofollow" title="Add to&nbsp;Slashdot"><img class="social_img" src="http://rainstorms.me.uk/blog/wp-content/plugins/social-bookmarks/images/slashdot.png" title="Add to&nbsp;Slashdot" alt="Add to&nbsp;Slashdot" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.stumbleupon.com/submit?url=http%3A%2F%2Frainstorms.me.uk%2Fblog%2F2008%2F03%2F18%2Fsql-server-express-edition%2F&amp;title=SQL+Server+Express+Edition" rel="nofollow" title="Add to&nbsp;Stumble Upon"><img class="social_img" src="http://rainstorms.me.uk/blog/wp-content/plugins/social-bookmarks/images/stumbleupon.png" title="Add to&nbsp;Stumble Upon" alt="Add to&nbsp;Stumble Upon" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.shoutwire.com/?p=submit&amp;link=http%3A%2F%2Frainstorms.me.uk%2Fblog%2F2008%2F03%2F18%2Fsql-server-express-edition%2F" rel="nofollow" title="Add to&nbsp;Shoutwire"><img class="social_img" src="http://rainstorms.me.uk/blog/wp-content/plugins/social-bookmarks/images/shoutwire.png" title="Add to&nbsp;Shoutwire" alt="Add to&nbsp;Shoutwire" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.technorati.com/faves?add=http%3A%2F%2Frainstorms.me.uk%2Fblog%2F2008%2F03%2F18%2Fsql-server-express-edition%2F" rel="nofollow" title="Add to&nbsp;Technorati"><img class="social_img" src="http://rainstorms.me.uk/blog/wp-content/plugins/social-bookmarks/images/technorati.png" title="Add to&nbsp;Technorati" alt="Add to&nbsp;Technorati" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://myweb2.search.yahoo.com/myresults/bookmarklet?u=http%3A%2F%2Frainstorms.me.uk%2Fblog%2F2008%2F03%2F18%2Fsql-server-express-edition%2F&amp;t=SQL+Server+Express+Edition" rel="nofollow" title="Add to&nbsp;Yahoo My Web"><img class="social_img" src="http://rainstorms.me.uk/blog/wp-content/plugins/social-bookmarks/images/yahoo.png" title="Add to&nbsp;Yahoo My Web" alt="Add to&nbsp;Yahoo My Web" /></a>
<br />
</div>
</div>
<!-- Social Bookmarks END -->


<p>No related posts.</p>
<p>Related posts brought to you by <a href='http://yarpp.org'>Yet Another Related Posts Plugin</a>.</p>]]></content:encoded>
			<wfw:commentRss>http://rainstorms.me.uk/blog/2008/03/18/sql-server-express-edition/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Distinct in Linq to SQL</title>
		<link>http://rainstorms.me.uk/blog/2008/03/12/distinct-in-linq-to-sql/</link>
		<comments>http://rainstorms.me.uk/blog/2008/03/12/distinct-in-linq-to-sql/#comments</comments>
		<pubDate>Wed, 12 Mar 2008 19:18:44 +0000</pubDate>
		<dc:creator>wizzard</dc:creator>
				<category><![CDATA[.NET]]></category>
		<category><![CDATA[.NET 3.5]]></category>
		<category><![CDATA[Coding]]></category>
		<category><![CDATA[Linq]]></category>
		<category><![CDATA[SQL]]></category>

		<guid isPermaLink="false">http://rainstorms.me.uk/blog/?p=5</guid>
		<description><![CDATA[I was trying to get Linq to SQL to do a Distinct query today, and found that it wasn&#8217;t quite so obvious how to do it. This works: - From item in table Select field Distinct This doesn&#8217;t: - From item in table Distinct Select field Neither does this: - From item in table Select [...]


No related posts.

Related posts brought to you by <a href='http://yarpp.org'>Yet Another Related Posts Plugin</a>.]]></description>
			<content:encoded><![CDATA[<p>I was trying to get Linq to SQL to do a Distinct query today, and found that it wasn&#8217;t quite so obvious how to do it.</p>
<p>This works: -</p>
<p>From <em>item</em> in <em>table</em> Select <em>field</em> Distinct</p>
<p>This doesn&#8217;t: -</p>
<p>From <em>item</em> in <em>table</em> Distinct Select <em>field</em></p>
<p>Neither does this: -</p>
<p>From <em>item</em> in <em>table</em> Select <em>field</em>.Distinct</p>
<p>Note that all 3 of these appear fine with Intellisense</p>
<!-- Social Bookmarks BEGIN -->
<div class="social_bookmark">
<a><strong><em>Bookmark this post</em></strong></a>
<br />
<div class="d">
<br />
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://del.icio.us/post?url=http%3A%2F%2Frainstorms.me.uk%2Fblog%2F2008%2F03%2F12%2Fdistinct-in-linq-to-sql%2F&amp;title=Distinct+in+Linq+to+SQL" rel="nofollow" title="Add to&nbsp;Del.icio.us"><img class="social_img" src="http://rainstorms.me.uk/blog/wp-content/plugins/social-bookmarks/images/delicious.png" title="Add to&nbsp;Del.icio.us" alt="Add to&nbsp;Del.icio.us" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://digg.com/submit?phase=2&amp;url=http%3A%2F%2Frainstorms.me.uk%2Fblog%2F2008%2F03%2F12%2Fdistinct-in-linq-to-sql%2F&amp;title=Distinct+in+Linq+to+SQL" rel="nofollow" title="Add to&nbsp;digg"><img class="social_img" src="http://rainstorms.me.uk/blog/wp-content/plugins/social-bookmarks/images/digg.png" title="Add to&nbsp;digg" alt="Add to&nbsp;digg" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.dotnetkicks.com/kick/?url=http%3A%2F%2Frainstorms.me.uk%2Fblog%2F2008%2F03%2F12%2Fdistinct-in-linq-to-sql%2F&amp;title=Distinct+in+Linq+to+SQL" rel="nofollow" title="Add to&nbsp;DotNetKicks"><img class="social_img" src="http://rainstorms.me.uk/blog/wp-content/plugins/social-bookmarks/images/dotnetkicks.png" title="Add to&nbsp;DotNetKicks" alt="Add to&nbsp;DotNetKicks" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.facebook.com/sharer.php?u=http%3A%2F%2Frainstorms.me.uk%2Fblog%2F2008%2F03%2F12%2Fdistinct-in-linq-to-sql%2F" rel="nofollow" title="Add to&nbsp;Facebook"><img class="social_img" src="http://rainstorms.me.uk/blog/wp-content/plugins/social-bookmarks/images/facebook.png" title="Add to&nbsp;Facebook" alt="Add to&nbsp;Facebook" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://FriendSite.com/users/bookmarks/?u=http%3A%2F%2Frainstorms.me.uk%2Fblog%2F2008%2F03%2F12%2Fdistinct-in-linq-to-sql%2F&amp;t=Distinct+in+Linq+to+SQL" rel="nofollow" title="Add to&nbsp;FriendSite"><img class="social_img" src="http://rainstorms.me.uk/blog/wp-content/plugins/social-bookmarks/images/friendsite.png" title="Add to&nbsp;FriendSite" alt="Add to&nbsp;FriendSite" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.google.com/bookmarks/mark?op=edit&amp;output=popup&amp;bkmk=http%3A%2F%2Frainstorms.me.uk%2Fblog%2F2008%2F03%2F12%2Fdistinct-in-linq-to-sql%2F&amp;title=Distinct+in+Linq+to+SQL" rel="nofollow" title="Add to&nbsp;Google Bookmarks"><img class="social_img" src="http://rainstorms.me.uk/blog/wp-content/plugins/social-bookmarks/images/google.png" title="Add to&nbsp;Google Bookmarks" alt="Add to&nbsp;Google Bookmarks" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://reddit.com/submit?url=http%3A%2F%2Frainstorms.me.uk%2Fblog%2F2008%2F03%2F12%2Fdistinct-in-linq-to-sql%2F&amp;title=Distinct+in+Linq+to+SQL" rel="nofollow" title="Add to&nbsp;reddit"><img class="social_img" src="http://rainstorms.me.uk/blog/wp-content/plugins/social-bookmarks/images/reddit.png" title="Add to&nbsp;reddit" alt="Add to&nbsp;reddit" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://slashdot.org/bookmark.pl?url=http%3A%2F%2Frainstorms.me.uk%2Fblog%2F2008%2F03%2F12%2Fdistinct-in-linq-to-sql%2F&amp;title=Distinct+in+Linq+to+SQL" rel="nofollow" title="Add to&nbsp;Slashdot"><img class="social_img" src="http://rainstorms.me.uk/blog/wp-content/plugins/social-bookmarks/images/slashdot.png" title="Add to&nbsp;Slashdot" alt="Add to&nbsp;Slashdot" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.stumbleupon.com/submit?url=http%3A%2F%2Frainstorms.me.uk%2Fblog%2F2008%2F03%2F12%2Fdistinct-in-linq-to-sql%2F&amp;title=Distinct+in+Linq+to+SQL" rel="nofollow" title="Add to&nbsp;Stumble Upon"><img class="social_img" src="http://rainstorms.me.uk/blog/wp-content/plugins/social-bookmarks/images/stumbleupon.png" title="Add to&nbsp;Stumble Upon" alt="Add to&nbsp;Stumble Upon" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.shoutwire.com/?p=submit&amp;link=http%3A%2F%2Frainstorms.me.uk%2Fblog%2F2008%2F03%2F12%2Fdistinct-in-linq-to-sql%2F" rel="nofollow" title="Add to&nbsp;Shoutwire"><img class="social_img" src="http://rainstorms.me.uk/blog/wp-content/plugins/social-bookmarks/images/shoutwire.png" title="Add to&nbsp;Shoutwire" alt="Add to&nbsp;Shoutwire" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.technorati.com/faves?add=http%3A%2F%2Frainstorms.me.uk%2Fblog%2F2008%2F03%2F12%2Fdistinct-in-linq-to-sql%2F" rel="nofollow" title="Add to&nbsp;Technorati"><img class="social_img" src="http://rainstorms.me.uk/blog/wp-content/plugins/social-bookmarks/images/technorati.png" title="Add to&nbsp;Technorati" alt="Add to&nbsp;Technorati" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://myweb2.search.yahoo.com/myresults/bookmarklet?u=http%3A%2F%2Frainstorms.me.uk%2Fblog%2F2008%2F03%2F12%2Fdistinct-in-linq-to-sql%2F&amp;t=Distinct+in+Linq+to+SQL" rel="nofollow" title="Add to&nbsp;Yahoo My Web"><img class="social_img" src="http://rainstorms.me.uk/blog/wp-content/plugins/social-bookmarks/images/yahoo.png" title="Add to&nbsp;Yahoo My Web" alt="Add to&nbsp;Yahoo My Web" /></a>
<br />
</div>
</div>
<!-- Social Bookmarks END -->


<p>No related posts.</p>
<p>Related posts brought to you by <a href='http://yarpp.org'>Yet Another Related Posts Plugin</a>.</p>]]></content:encoded>
			<wfw:commentRss>http://rainstorms.me.uk/blog/2008/03/12/distinct-in-linq-to-sql/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>

