<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" media="screen" href="/~d/styles/rss2full.xsl"?><?xml-stylesheet type="text/css" media="screen" href="http://feeds.feedburner.com/~d/styles/itemcontent.css"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:trackback="http://madskills.com/public/xml/rss/module/trackback/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:copyright="http://blogs.law.harvard.edu/tech/rss" xmlns:image="http://purl.org/rss/1.0/modules/image/" xmlns:creativeCommons="http://backend.userland.com/creativeCommonsRssModule" xmlns:feedburner="http://rssnamespace.org/feedburner/ext/1.0" version="2.0">
    <channel>
        <title>I want some Moore</title>
        <link>http://weblogs.sqlteam.com/mladenp/Default.aspx</link>
        <description>Blog about stuff and things and stuff.  Mostly about SQL server and .Net</description>
        <language>en-US</language>
        <copyright>Mladen Prajdić</copyright>
        <managingEditor>spirit1_fe@yahoo.com</managingEditor>
        <generator>Subtext Version 1.9.4.0</generator>
        <image><link>http://creativecommons.org/licenses/by/3.0/</link><url>http://creativecommons.org/images/public/somerights20.gif</url><title>Some Rights Reserved</title></image>
        <creativeCommons:license>http://creativecommons.org/licenses/by/3.0/</creativeCommons:license><atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="self" href="http://feeds.feedburner.com/mladenp" type="application/rss+xml" /><feedburner:emailServiceId>mladenp</feedburner:emailServiceId><feedburner:feedburnerHostname>http://feedburner.google.com</feedburner:feedburnerHostname><atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="hub" href="http://pubsubhubbub.appspot.com" /><item>
            <title>SSMS Tools Pack 1.7.5.1 is out! Bug fixes for my international users.</title>
            <link>http://feedproxy.google.com/~r/mladenp/~3/LRXdAUMRWRw/SSMS-Tools-Pack-1.7.5.1-is-out-Bug-fixes-for-my.aspx</link>
            <description>&lt;p&gt;Due to a bug i haven’t anticipated, a whole load of users with non English SSMS couldn’t install the latest SSMS Tools Pack 1.7.&lt;/p&gt;
&lt;p&gt;The SSMS Tools Pack 1.7.5.1 fixes this as well as 1 other major bug that was reported and 3 smaller ones.&lt;/p&gt;
&lt;p&gt;The &lt;a target="_blank" href="http://www.ssmstoolspack.com/Features"&gt;&lt;strong&gt;&lt;font color="#004080"&gt;feature list&lt;/font&gt;&lt;/strong&gt;&lt;/a&gt; hasn’t changed.&lt;/p&gt;
&lt;p&gt; &lt;/p&gt;
&lt;p&gt;&lt;strong&gt;You can simply reinstall 1.7.5.1 over the 1.7.0.0.&lt;/strong&gt; &lt;/p&gt;
&lt;p&gt;If you’re still on 1.5 or less then you’ll have to manually uninstall it and install 1.7.5.1.&lt;/p&gt;
&lt;p&gt; &lt;/p&gt;
&lt;p&gt;&lt;strong&gt;You can download the new version &lt;/strong&gt;&lt;a target="_blank" href="http://www.ssmstoolspack.com/Download"&gt;&lt;font color="#004080"&gt;&lt;strong&gt;here&lt;/strong&gt;&lt;/font&gt;&lt;/a&gt;&lt;strong&gt;.&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt; &lt;/p&gt;
&lt;p&gt;Hopefully this will bring back joy to everyone :)&lt;/p&gt;&lt;img src="http://weblogs.sqlteam.com/mladenp/aggbug/61034.aspx" width="1" height="1" /&gt;
&lt;p&gt;&lt;a href="http://feedads.g.doubleclick.net/~a/1TnvSR7tc_R729wVCDmzhqDITXs/0/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/1TnvSR7tc_R729wVCDmzhqDITXs/0/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;br/&gt;
&lt;a href="http://feedads.g.doubleclick.net/~a/1TnvSR7tc_R729wVCDmzhqDITXs/1/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/1TnvSR7tc_R729wVCDmzhqDITXs/1/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;/p&gt;</description>
            <dc:creator>Mladen Prajdić</dc:creator>
            <guid isPermaLink="false">http://weblogs.sqlteam.com/mladenp/archive/2009/11/02/SSMS-Tools-Pack-1.7.5.1-is-out-Bug-fixes-for-my.aspx</guid>
            <pubDate>Mon, 02 Nov 2009 17:24:26 GMT</pubDate>
            <wfw:comment>http://weblogs.sqlteam.com/mladenp/comments/61034.aspx</wfw:comment>
            <comments>http://weblogs.sqlteam.com/mladenp/archive/2009/11/02/SSMS-Tools-Pack-1.7.5.1-is-out-Bug-fixes-for-my.aspx#feedback</comments>
            <wfw:commentRss>http://weblogs.sqlteam.com/mladenp/comments/commentRss/61034.aspx</wfw:commentRss>
            <trackback:ping>http://weblogs.sqlteam.com/mladenp/services/trackbacks/61034.aspx</trackback:ping>
        <feedburner:origLink>http://weblogs.sqlteam.com/mladenp/archive/2009/11/02/SSMS-Tools-Pack-1.7.5.1-is-out-Bug-fixes-for-my.aspx</feedburner:origLink></item>
        <item>
            <title>SSMS Tools Pack 1.7 is out! New feature: SQL Snippets</title>
            <link>http://feedproxy.google.com/~r/mladenp/~3/KNrW5BvJVJk/SSMS-Tools-Pack-1.7-is-out-New-feature-SQL-Snippets.aspx</link>
            <description>&lt;p&gt;Ladies and gentlemen, boys and girls, the STP is back to rock your world! &lt;/p&gt;
The new feature is &lt;a href="http://www.ssmstoolspack.com/Features?f=0"&gt;&lt;strong&gt;&lt;font color="#004080"&gt;SQL Snippets&lt;/font&gt;&lt;/strong&gt;&lt;/a&gt; to speed up your development.
&lt;p&gt;&lt;br /&gt;
This new version brings one completely new option, full GUI redesign, completely rewritten installer, improved error handling and reporting, bug fixes and old features improvements. &lt;br /&gt;
Type in the assigned shortcut, press enter or tab and get the snippet you need. &lt;br /&gt;
It's quick, clean and saves time!  &lt;br /&gt;
&lt;br /&gt;
Some of more visible improved features include: &lt;/p&gt;
&lt;ul id="features"&gt;
    &lt;li&gt;Completely new installer using the powerful &lt;a target="_blank" href="http://wix.sourceforge.net/"&gt;&lt;strong&gt;&lt;font color="#004080"&gt;Windows Installer XML (WiX) toolset&lt;/font&gt;&lt;/strong&gt;&lt;/a&gt;. Now there’s only one MSI installer file for all versions with automatic detection of which versions should be installed. &lt;br /&gt;
    &lt;/li&gt;
    &lt;li&gt;Improved search in &lt;a href="http://www.ssmstoolspack.com/Features?f=2"&gt;&lt;strong&gt;&lt;font color="#004080"&gt;Current Window History&lt;/font&gt;&lt;/strong&gt;&lt;/a&gt;. &lt;br /&gt;
    &lt;/li&gt;
    &lt;li&gt;Added search through views in &lt;a href="http://www.ssmstoolspack.com/Features?f=4"&gt;&lt;strong&gt;&lt;font color="#004080"&gt;Search Table/View or Database Data&lt;/font&gt;&lt;/strong&gt;&lt;/a&gt;. &lt;br /&gt;
    &lt;/li&gt;
    &lt;li&gt;Added option to &lt;a href="http://www.ssmstoolspack.com/Features?f=6"&gt;&lt;strong&gt;&lt;font color="#004080"&gt;Copy execution plan bitmaps to file&lt;/font&gt;&lt;/strong&gt;&lt;/a&gt;. &lt;br /&gt;
    &lt;/li&gt;
    &lt;li&gt;New features like &lt;a href="http://www.ssmstoolspack.com/Features?f=13"&gt;&lt;strong&gt;&lt;font color="#004080"&gt;Automatic web proxy detection and “Log everything” options&lt;/font&gt;&lt;/strong&gt;&lt;/a&gt; in General Options. &lt;br /&gt;
    &lt;/li&gt;
    &lt;li&gt;Improved logging and direct error reporting features using the awesome &lt;a target="_blank" href="http://www.postsharp.org/"&gt;&lt;strong&gt;&lt;font color="#004080"&gt;PostSharp&lt;/font&gt;&lt;/strong&gt;&lt;/a&gt; AOP framework. &lt;br /&gt;
    &lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;SSMS 2008 R2 is supported but expect quirks in it due to the CTP status.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Due to a folder naming installer bug in version 1.5 please uninstall any and all previous versions before installing the 1.7 version.&lt;/strong&gt;&lt;/p&gt;&lt;img src="http://weblogs.sqlteam.com/mladenp/aggbug/61030.aspx" width="1" height="1" /&gt;
&lt;p&gt;&lt;a href="http://feedads.g.doubleclick.net/~a/ABoCI2JBXtQHex-UPLKqY8EbAX0/0/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/ABoCI2JBXtQHex-UPLKqY8EbAX0/0/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;br/&gt;
&lt;a href="http://feedads.g.doubleclick.net/~a/ABoCI2JBXtQHex-UPLKqY8EbAX0/1/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/ABoCI2JBXtQHex-UPLKqY8EbAX0/1/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;/p&gt;</description>
            <dc:creator>Mladen Prajdić</dc:creator>
            <guid isPermaLink="false">http://weblogs.sqlteam.com/mladenp/archive/2009/10/26/SSMS-Tools-Pack-1.7-is-out-New-feature-SQL-Snippets.aspx</guid>
            <pubDate>Mon, 26 Oct 2009 12:49:13 GMT</pubDate>
            <wfw:comment>http://weblogs.sqlteam.com/mladenp/comments/61030.aspx</wfw:comment>
            <comments>http://weblogs.sqlteam.com/mladenp/archive/2009/10/26/SSMS-Tools-Pack-1.7-is-out-New-feature-SQL-Snippets.aspx#feedback</comments>
            <slash:comments>14</slash:comments>
            <wfw:commentRss>http://weblogs.sqlteam.com/mladenp/comments/commentRss/61030.aspx</wfw:commentRss>
            <trackback:ping>http://weblogs.sqlteam.com/mladenp/services/trackbacks/61030.aspx</trackback:ping>
        <feedburner:origLink>http://weblogs.sqlteam.com/mladenp/archive/2009/10/26/SSMS-Tools-Pack-1.7-is-out-New-feature-SQL-Snippets.aspx</feedburner:origLink></item>
        <item>
            <title>SQL Server - How to get the whole group of duplicate rows</title>
            <link>http://feedproxy.google.com/~r/mladenp/~3/lbztusDk-N0/SQL-Server---How-to-get-the-whole-group-of.aspx</link>
            <description>&lt;p&gt;We all know how to find only duplicated rows in a table. &lt;/p&gt; &lt;p&gt;Since SQL Server 2005 this became really simple using a ROW_NUMBER() window function like this:&lt;/p&gt; &lt;div&gt;&lt;pre class="csharpcode"&gt;&lt;span class="kwrd"&gt;USE&lt;/span&gt; AdventureWorks
&lt;span class="kwrd"&gt;GO&lt;/span&gt;
;&lt;span class="kwrd"&gt;WITH&lt;/span&gt; cteDupes &lt;span class="kwrd"&gt;AS&lt;/span&gt; 
(
    &lt;span class="rem"&gt;-- find all rows that have the same AddressLine1 and City. &lt;/span&gt;
    &lt;span class="rem"&gt;-- we consider those rows are duplicates so we partition on them    &lt;/span&gt;
    &lt;span class="kwrd"&gt;SELECT&lt;/span&gt;  ROW_NUMBER() &lt;span class="kwrd"&gt;OVER&lt;/span&gt;(PARTITION &lt;span class="kwrd"&gt;BY&lt;/span&gt; AddressLine1, City &lt;span class="kwrd"&gt;ORDER&lt;/span&gt; &lt;span class="kwrd"&gt;BY&lt;/span&gt; AddressID) &lt;span class="kwrd"&gt;AS&lt;/span&gt; RN,
            *
    &lt;span class="kwrd"&gt;FROM&lt;/span&gt;    Person.Address
)
&lt;span class="kwrd"&gt;SELECT&lt;/span&gt;  *
&lt;span class="kwrd"&gt;FROM&lt;/span&gt;    cteDupes
&lt;span class="kwrd"&gt;WHERE&lt;/span&gt;   RN &amp;gt; 1
&lt;span class="kwrd"&gt;ORDER&lt;/span&gt; &lt;span class="kwrd"&gt;BY&lt;/span&gt; AddressLine1, City, AddressID&lt;/pre&gt;&lt;pre class="csharpcode"&gt; &lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;The IO for this method is great. We get only one pass through the table:&lt;/p&gt;
&lt;div&gt;&lt;pre class="csharpcode"&gt;Table &lt;span class="str"&gt;'Address'&lt;/span&gt;. Scan count 1, logical reads 280, physical reads 0, read-ahead reads 0, lob logical reads 0, lob physical reads 0, lob read-ahead reads 0.&lt;/pre&gt;&lt;pre class="csharpcode"&gt; &lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;However the problem with this code is that it returns only the duplicated rows and not the original row the duplicates originated from.&lt;/p&gt;
&lt;h4&gt;Good way&lt;/h4&gt;
&lt;p&gt;We want a fast way of getting the whole duplicated group. My first attempt was to use the Count(*) with OVER to get the group count in each row like this:&lt;/p&gt;
&lt;div&gt;&lt;pre class="csharpcode"&gt;&lt;span class="kwrd"&gt;USE&lt;/span&gt; AdventureWorks
&lt;span class="kwrd"&gt;GO&lt;/span&gt;
;&lt;span class="kwrd"&gt;WITH&lt;/span&gt; cteDupes &lt;span class="kwrd"&gt;AS&lt;/span&gt; 
(
    &lt;span class="rem"&gt;-- find all rows that have the same AddressLine1 and City. &lt;/span&gt;
    &lt;span class="rem"&gt;-- we consider those rows are duplicates so we partition on them&lt;/span&gt;
    &lt;span class="kwrd"&gt;SELECT&lt;/span&gt;  &lt;span class="kwrd"&gt;COUNT&lt;/span&gt;(*) &lt;span class="kwrd"&gt;OVER&lt;/span&gt;(PARTITION &lt;span class="kwrd"&gt;BY&lt;/span&gt; AddressLine1, City ) &lt;span class="kwrd"&gt;AS&lt;/span&gt; CNT,
            *
    &lt;span class="kwrd"&gt;FROM&lt;/span&gt;    Person.Address
)
&lt;span class="kwrd"&gt;SELECT&lt;/span&gt;  *
&lt;span class="kwrd"&gt;FROM&lt;/span&gt;    cteDupes
&lt;span class="kwrd"&gt;WHERE&lt;/span&gt;   CNT &amp;gt; 1
&lt;span class="kwrd"&gt;ORDER&lt;/span&gt; &lt;span class="kwrd"&gt;BY&lt;/span&gt; AddressLine1, City, AddressID&lt;/pre&gt;&lt;pre class="csharpcode"&gt; &lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;But looking at the IO this caused made my head explode and i wanted a better way.&lt;/p&gt;
&lt;div&gt;&lt;pre class="csharpcode"&gt;Table &lt;span class="str"&gt;'Worktable'&lt;/span&gt;. Scan count 3, logical reads 117473, physical reads 0, read-ahead reads 0, lob logical reads 0, lob physical reads 0, lob read-ahead reads 0.
Table &lt;span class="str"&gt;'Address'&lt;/span&gt;. Scan count 1, logical reads 280, physical reads 0, read-ahead reads 0, lob logical reads 0, lob physical reads 0, lob read-ahead reads 0.&lt;/pre&gt;&lt;/div&gt;
&lt;h4&gt;Better way&lt;/h4&gt;
&lt;p&gt;We could get the same thing by using 2 ROW_NUMBER()-ed column, one in ascending and the other on descending order like this: &lt;/p&gt;
&lt;div&gt;&lt;pre class="csharpcode"&gt;&lt;span class="kwrd"&gt;USE&lt;/span&gt; AdventureWorks
&lt;span class="kwrd"&gt;GO&lt;/span&gt;
;&lt;span class="kwrd"&gt;WITH&lt;/span&gt; cteDupes &lt;span class="kwrd"&gt;AS&lt;/span&gt; 
(
    &lt;span class="rem"&gt;-- find all rows that have the same AddressLine1 and City. &lt;/span&gt;
    &lt;span class="rem"&gt;-- we consider those rows are duplicates so we partition on them&lt;/span&gt;
    &lt;span class="kwrd"&gt;SELECT&lt;/span&gt;  ROW_NUMBER() &lt;span class="kwrd"&gt;OVER&lt;/span&gt;(PARTITION &lt;span class="kwrd"&gt;BY&lt;/span&gt; AddressLine1, City &lt;span class="kwrd"&gt;ORDER&lt;/span&gt; &lt;span class="kwrd"&gt;BY&lt;/span&gt; AddressID &lt;span class="kwrd"&gt;DESC&lt;/span&gt;) &lt;span class="kwrd"&gt;AS&lt;/span&gt; RND,
            ROW_NUMBER() &lt;span class="kwrd"&gt;OVER&lt;/span&gt;(PARTITION &lt;span class="kwrd"&gt;BY&lt;/span&gt; AddressLine1, City &lt;span class="kwrd"&gt;ORDER&lt;/span&gt; &lt;span class="kwrd"&gt;BY&lt;/span&gt; AddressID)      &lt;span class="kwrd"&gt;AS&lt;/span&gt; RNA,
            *
    &lt;span class="kwrd"&gt;FROM&lt;/span&gt;    Person.Address
)
&lt;span class="kwrd"&gt;SELECT&lt;/span&gt;  *
&lt;span class="kwrd"&gt;FROM&lt;/span&gt;    cteDupes
&lt;span class="rem"&gt;-- this condition removes the rows that don’t have duplicates &lt;/span&gt;
&lt;span class="rem"&gt;-- RNA-RND = 0 gets all odd rows in the group: 1st, 3rd, etc...&lt;/span&gt;
&lt;span class="rem"&gt;-- RNA = 1 AND RND = 1 limit those rows to those groups that don’t have duplicates &lt;/span&gt;
&lt;span class="rem"&gt;-- because if there’s only one row both RNA and RND will be 1&lt;/span&gt;
&lt;span class="rem"&gt;-- by negating the condition we return the whole duplicated group&lt;/span&gt;
&lt;span class="kwrd"&gt;WHERE&lt;/span&gt; &lt;span class="kwrd"&gt;NOT&lt;/span&gt; (RNA-RND = 0 &lt;span class="kwrd"&gt;AND&lt;/span&gt; RNA = 1 &lt;span class="kwrd"&gt;AND&lt;/span&gt; RND = 1)&lt;/pre&gt;&lt;pre class="csharpcode"&gt;&lt;span class="kwrd"&gt;ORDER&lt;/span&gt; &lt;span class="kwrd"&gt;BY&lt;/span&gt; AddressLine1, City, AddressID&lt;/pre&gt;&lt;pre class="csharpcode"&gt; &lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;This made the IO a normal single pass at the table.&lt;/p&gt;
&lt;div&gt;&lt;pre class="csharpcode"&gt;Table &lt;span class="str"&gt;'Address'&lt;/span&gt;. Scan count 1, logical reads 280, physical reads 0, read-ahead reads 0, lob logical reads 0, lob physical reads 0, lob read-ahead reads 0.&lt;/pre&gt;&lt;pre class="csharpcode"&gt; &lt;/pre&gt;&lt;/div&gt;
&lt;p&gt; &lt;/p&gt;
&lt;p&gt;If anyone has a better way do let me know.&lt;/p&gt;&lt;a href="http://www.dotnetkicks.com/kick/?url=http%3a%2f%2fweblogs.sqlteam.com%2fmladenp%2farchive%2f2009%2f10%2f15%2fSQL-Server---How-to-get-the-whole-group-of.aspx"&gt;&lt;img border="0" alt="kick it on DotNetKicks.com" src="http://www.dotnetkicks.com/Services/Images/KickItImageGenerator.ashx?url=http%3a%2f%2fweblogs.sqlteam.com%2fmladenp%2farchive%2f2009%2f10%2f15%2fSQL-Server---How-to-get-the-whole-group-of.aspx" /&gt;&lt;/a&gt;&lt;img src="http://weblogs.sqlteam.com/mladenp/aggbug/61023.aspx" width="1" height="1" /&gt;
&lt;p&gt;&lt;a href="http://feedads.g.doubleclick.net/~a/Y9jWfpMgtr2rwVUjv3dXIuJj_lI/0/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/Y9jWfpMgtr2rwVUjv3dXIuJj_lI/0/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;br/&gt;
&lt;a href="http://feedads.g.doubleclick.net/~a/Y9jWfpMgtr2rwVUjv3dXIuJj_lI/1/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/Y9jWfpMgtr2rwVUjv3dXIuJj_lI/1/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;/p&gt;</description>
            <dc:creator>Mladen Prajdić</dc:creator>
            <guid isPermaLink="false">http://weblogs.sqlteam.com/mladenp/archive/2009/10/15/SQL-Server---How-to-get-the-whole-group-of.aspx</guid>
            <pubDate>Thu, 15 Oct 2009 11:53:32 GMT</pubDate>
            <wfw:comment>http://weblogs.sqlteam.com/mladenp/comments/61023.aspx</wfw:comment>
            <comments>http://weblogs.sqlteam.com/mladenp/archive/2009/10/15/SQL-Server---How-to-get-the-whole-group-of.aspx#feedback</comments>
            <slash:comments>4</slash:comments>
            <wfw:commentRss>http://weblogs.sqlteam.com/mladenp/comments/commentRss/61023.aspx</wfw:commentRss>
            <trackback:ping>http://weblogs.sqlteam.com/mladenp/services/trackbacks/61023.aspx</trackback:ping>
        <feedburner:origLink>http://weblogs.sqlteam.com/mladenp/archive/2009/10/15/SQL-Server---How-to-get-the-whole-group-of.aspx</feedburner:origLink></item>
        <item>
            <title>Why I prefer surrogate keys instead of natural keys in database design</title>
            <link>http://feedproxy.google.com/~r/mladenp/~3/gAVvLHMV_fc/Why-I-prefer-surrogate-keys-instead-of-natural-keys-in.aspx</link>
            <description>&lt;p&gt;Simply put:&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;I prefer using surrogate keys because natural keys are by default a subject to change which is a bad behavior for a row identifier.&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;But let’s dig a bit deeper into each key type to see why this is. Here’s a little table with column names that tell us what kind of a key each column is.&lt;/p&gt;
&lt;p&gt;&lt;a href="http://weblogs.sqlteam.com/images/weblogs_sqlteam_com/mladenp/WindowsLiveWriter/WhyIprefersurrogatekeysinsteadofnaturalk_101FF/image_6.png"&gt;&lt;img style="BORDER-RIGHT-WIDTH: 0px; DISPLAY: inline; BORDER-TOP-WIDTH: 0px; BORDER-BOTTOM-WIDTH: 0px; BORDER-LEFT-WIDTH: 0px" title="image" border="0" alt="image" width="722" height="62" src="http://weblogs.sqlteam.com/images/weblogs_sqlteam_com/mladenp/WindowsLiveWriter/WhyIprefersurrogatekeysinsteadofnaturalk_101FF/image_thumb_2.png" /&gt;&lt;/a&gt; &lt;/p&gt;
&lt;h4&gt;Surrogate keys&lt;/h4&gt;
&lt;p&gt;A surrogate key is a row identifier that has no connection to the data attributes in the row but simply makes the whole row unique. And that property is also the downside of it. &lt;strong&gt;Because it has no connection to the data attributes we can have two rows with the exact same data in all columns except the key column&lt;/strong&gt;. This is usually handled at the application side and is an acceptable downside.&lt;/p&gt;
&lt;p&gt;An example of a surrogate key is an integer identity or a GIUD unique identifier. I’ve never seen another data type being used as a surrogate key successfully. Both have their pros and cons though.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;&lt;em&gt;GUID unique identifier&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;GUID is globally unique 16 byte long data type that can have 2&lt;sup&gt;128&lt;/sup&gt; different values. This makes it ideal for scenarios with multiple server moving data from one to another like replication. &lt;/p&gt;
&lt;p&gt;However for a key 16 bytes is really a lot. This causes less data to be available on a single data page which in turn causes extra IO activity because it has to retrieve more data pages. Another issue about it is that is causes perfect page splits in a clustered index because it has &lt;strong&gt;random 100% selectivity&lt;/strong&gt; in it’s entire data type range.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;&lt;em&gt;Integer identity&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;Integer identity is either 4 byte INT with range from -2,147,483,648 to 2,147,483,647 or 8 byte BIGINT with range from -9,223,372,036,854,775,808 to 9,223,372,036,854,775,807. In 99.9% of cases this range is split in half because the default setting in SQL Server is to start any integer data type from 0. As this is a surrogate key this makes no sense and there’s no reason it shouldn’t start from the min value. &lt;/p&gt;
&lt;p&gt;It is a small data type which gives it the advantage of having more data in the data pages thus needing less IO for the same amount of data. Unlike the GIUD unique identifier the integer identity has &lt;strong&gt;ever increasing 100% selectivity&lt;/strong&gt; in it’s entire data type range. This makes it a perfect candidate for a clustered because it doesn’t cause page splits. If it actually is an appropriate candidate for a clustered index is a different matter.&lt;/p&gt;
&lt;p&gt;Its downside is that it is not ideal for multi server scenarios although it can be done by using another tinyint column identifying a location and making it a covering row identifier over ID and LocationId columns.&lt;/p&gt;
&lt;p&gt;And remember: &lt;strong&gt;Never tie any business logic to the surrogate key other than simple CRUD operations.&lt;/strong&gt; &lt;/p&gt;
&lt;p&gt;&lt;strong&gt;&lt;/strong&gt;&lt;/p&gt;
&lt;h4&gt;Natural Keys&lt;/h4&gt;
&lt;p&gt;A natural key is a row identifier composed of data that uniquely describes data using its own attributes. An example of a natural key is social security number or other government issued number. &lt;/p&gt;
&lt;p&gt;However this presents a huge problem from the physical database implementation point of view. In most databases a row identifier is usually also the basis for the &lt;a target="_blank" href="http://weblogs.sqlteam.com/mladenp/archive/2007/09/18/Back-To-Basics-What-is-a-Clustered-and-a-Non-Clustered.aspx"&gt;&lt;strong&gt;&lt;font color="#004080"&gt;clustered index and non-clustered indexes&lt;/font&gt;&lt;/strong&gt;&lt;/a&gt;. But natural keys are by definition a subject to change. &lt;strong&gt;When the clustered index key is changed ALL indexes have to be rebuilt because non-clustered indexes contain the full key of the clustered index.&lt;/strong&gt; So every time the natural key, which is also a clustered index changes, all indexes have to be rebuilt. And this is not including changing the actual data type or it’s size, jut the key value.&lt;/p&gt;
&lt;p&gt;At this point someone might say: Yes Mladen you’re right about the theory of this but how many times have you seen the Natural key really change? Well so far I’ve seen it 2 times both with heavy consequences. It was 2 times too many.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;&lt;em&gt;Natural Key Fail Case 1:&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;It was a standard customer, product, order type of application. The key in this case was the 7 char long customer ID. It was a mix of first 3 letters of the customer name plus 4 numbers that also had some business meaning. The company got acquired by another company and a new customer numbering was introduced. Every key in that database had to be changed. Due to fully breaking changes to the database the whole application had to be modified and the store went offline for 3 months loosing the company a lot of profit. All this wouldn’t have happened if they had used surrogate keys.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;&lt;em&gt;Natural Key Fail Case 2:&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;This one was even more far reaching. In Slovenia (my home country) we have something called a Tax ID. This is an ID that is unique for companies and individuals so every person and every company has one for tax purposes. Many systems in Slovenia used it as the natural never changing key which sounded like a reasonable thing at the time. And it was so for over 30 years. Applications came and went. But in 2004 Slovenia entered into the European Union. So we had to modify the TaxId to European standards which means that every application using it had to be changed. I know of at least one company that went out of business because of this change. Again had they used a surrogate key the only change would be the length of the TaxId column.&lt;/p&gt;
&lt;p&gt;Because of all this I’ve come to the prefer the surrogate keys in majority of cases.&lt;/p&gt;
&lt;p&gt;Hopefully this gives you some insight why surrogates are in my opinion better suited as row identifiers. Although whichever you choose is still a matter of common sense and your business problem. The answer is always “It depends”.&lt;/p&gt;
&lt;p&gt; &lt;/p&gt;
&lt;a href="http://www.dotnetkicks.com/kick/?url=http%3a%2f%2fweblogs.sqlteam.com%2fmladenp%2farchive%2f2009%2f10%2f06%2fWhy-I-prefer-surrogate-keys-instead-of-natural-keys-in.aspx"&gt;&lt;img border="0" alt="kick it on DotNetKicks.com" src="http://www.dotnetkicks.com/Services/Images/KickItImageGenerator.ashx?url=http%3a%2f%2fweblogs.sqlteam.com%2fmladenp%2farchive%2f2009%2f10%2f06%2fWhy-I-prefer-surrogate-keys-instead-of-natural-keys-in.aspx" /&gt;&lt;/a&gt;&lt;img src="http://weblogs.sqlteam.com/mladenp/aggbug/61017.aspx" width="1" height="1" /&gt;
&lt;p&gt;&lt;a href="http://feedads.g.doubleclick.net/~a/PfuFT7ZjxKkE37HCKyJexRpFzuA/0/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/PfuFT7ZjxKkE37HCKyJexRpFzuA/0/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;br/&gt;
&lt;a href="http://feedads.g.doubleclick.net/~a/PfuFT7ZjxKkE37HCKyJexRpFzuA/1/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/PfuFT7ZjxKkE37HCKyJexRpFzuA/1/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;/p&gt;</description>
            <dc:creator>Mladen Prajdić</dc:creator>
            <guid isPermaLink="false">http://weblogs.sqlteam.com/mladenp/archive/2009/10/06/Why-I-prefer-surrogate-keys-instead-of-natural-keys-in.aspx</guid>
            <pubDate>Tue, 06 Oct 2009 11:17:11 GMT</pubDate>
            <wfw:comment>http://weblogs.sqlteam.com/mladenp/comments/61017.aspx</wfw:comment>
            <comments>http://weblogs.sqlteam.com/mladenp/archive/2009/10/06/Why-I-prefer-surrogate-keys-instead-of-natural-keys-in.aspx#feedback</comments>
            <slash:comments>48</slash:comments>
            <wfw:commentRss>http://weblogs.sqlteam.com/mladenp/comments/commentRss/61017.aspx</wfw:commentRss>
            <trackback:ping>http://weblogs.sqlteam.com/mladenp/services/trackbacks/61017.aspx</trackback:ping>
        <feedburner:origLink>http://weblogs.sqlteam.com/mladenp/archive/2009/10/06/Why-I-prefer-surrogate-keys-instead-of-natural-keys-in.aspx</feedburner:origLink></item>
        <item>
            <title>Why would Visual Studio build always rebuild a solution?</title>
            <link>http://feedproxy.google.com/~r/mladenp/~3/o4CNVc8BOHI/Why-would-Visual-Studio-build-always-rebuild-a-solution.aspx</link>
            <description>&lt;p&gt;Today I had an interesting problem. &lt;/p&gt;
&lt;p&gt;If I rebuilt my solution every thing would succeed but after that if i pressed F5 (build) the whole solution would get built again but it would error out. Now this doesn’t make any sense because the &lt;strong&gt;difference between Build and Rebuild is that Rebuild always compiles and links all files + all dependencies, while Build only compiles and links files that have changed since the last build&lt;/strong&gt;. So everything should be fine. The thing about our solution is that the we have some post build events that do some IL merge, etc… the problem was that rebuild ran those events while just build didn’t. So on build IL merge didn’t happen and I got the error when I pressed F5. &lt;/p&gt;
&lt;p&gt;It turned out that one dependant DLL that was included everywhere had a create date set to year 2049 and because of that the build process wanted to build everything every time since it thought that it had changed since it was in the future. Talk about going back to the future :)&lt;/p&gt;
&lt;p&gt; &lt;/p&gt;
&lt;p&gt;Moral of the story: &lt;strong&gt;If your build always builds your whole solution check for future dated files.&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt; &lt;/p&gt;
&lt;a href="http://www.dotnetkicks.com/kick/?url=http%3a%2f%2fweblogs.sqlteam.com%2fmladenp%2farchive%2f2009%2f08%2f24%2fWhy-would-Visual-Studio-build-always-rebuild-a-solution.aspx"&gt;&lt;img border="0" alt="kick it on DotNetKicks.com" src="http://www.dotnetkicks.com/Services/Images/KickItImageGenerator.ashx?url=http%3a%2f%2fweblogs.sqlteam.com%2fmladenp%2farchive%2f2009%2f08%2f24%2fWhy-would-Visual-Studio-build-always-rebuild-a-solution.aspx" /&gt;&lt;/a&gt;&lt;img src="http://weblogs.sqlteam.com/mladenp/aggbug/60996.aspx" width="1" height="1" /&gt;
&lt;p&gt;&lt;a href="http://feedads.g.doubleclick.net/~a/ixijnR7qoiMliQwwLEmFcnpvuZo/0/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/ixijnR7qoiMliQwwLEmFcnpvuZo/0/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;br/&gt;
&lt;a href="http://feedads.g.doubleclick.net/~a/ixijnR7qoiMliQwwLEmFcnpvuZo/1/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/ixijnR7qoiMliQwwLEmFcnpvuZo/1/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;/p&gt;</description>
            <dc:creator>Mladen Prajdić</dc:creator>
            <guid isPermaLink="false">http://weblogs.sqlteam.com/mladenp/archive/2009/08/24/Why-would-Visual-Studio-build-always-rebuild-a-solution.aspx</guid>
            <pubDate>Mon, 24 Aug 2009 11:31:43 GMT</pubDate>
            <wfw:comment>http://weblogs.sqlteam.com/mladenp/comments/60996.aspx</wfw:comment>
            <comments>http://weblogs.sqlteam.com/mladenp/archive/2009/08/24/Why-would-Visual-Studio-build-always-rebuild-a-solution.aspx#feedback</comments>
            <wfw:commentRss>http://weblogs.sqlteam.com/mladenp/comments/commentRss/60996.aspx</wfw:commentRss>
            <trackback:ping>http://weblogs.sqlteam.com/mladenp/services/trackbacks/60996.aspx</trackback:ping>
        <feedburner:origLink>http://weblogs.sqlteam.com/mladenp/archive/2009/08/24/Why-would-Visual-Studio-build-always-rebuild-a-solution.aspx</feedburner:origLink></item>
        <item>
            <title>The 24 hours of PASS</title>
            <link>http://feedproxy.google.com/~r/mladenp/~3/35Y3YWtRtGU/The-24-hours-of-PASS.aspx</link>
            <description>&lt;p&gt;On September 2nd this years biggest online SQL Server related event will begin.&lt;/p&gt;  &lt;p&gt;It’s the &lt;a href="http://24hours.sqlpass.org/" target="_blank"&gt;&lt;strong&gt;&lt;font color="#004080"&gt;24 hours of PASS&lt;/font&gt;&lt;/strong&gt;&lt;/a&gt;. &lt;/p&gt;  &lt;p&gt;The 24 one-hour presentations will begin at 00:00 GMT (UTC) on September 2, 2009 and it will last full 24 hours.&lt;/p&gt;  &lt;p&gt;The &lt;a href="http://24hours.sqlpass.org/Sessions.aspx" target="_blank"&gt;&lt;strong&gt;&lt;font color="#004080"&gt;speaker list&lt;/font&gt;&lt;/strong&gt;&lt;/a&gt; is impressive and topics are something to be desired.&lt;/p&gt;  &lt;p&gt; &lt;/p&gt;  &lt;p&gt;So on September 2nd prepare to have a sleepless day. &lt;/p&gt;  &lt;p&gt;&lt;strong&gt;Gentlemen, start your SQL engines!&lt;/strong&gt;&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;&lt;/strong&gt;&lt;/p&gt; &lt;a href="http://www.dotnetkicks.com/kick/?url=http%3a%2f%2fweblogs.sqlteam.com%2fmladenp%2farchive%2f2009%2f08%2f05%2fThe-24-hours-of-PASS.aspx"&gt;&lt;img border="0" alt="kick it on DotNetKicks.com" src="http://www.dotnetkicks.com/Services/Images/KickItImageGenerator.ashx?url=http%3a%2f%2fweblogs.sqlteam.com%2fmladenp%2farchive%2f2009%2f08%2f05%2fThe-24-hours-of-PASS.aspx" /&gt;&lt;/a&gt;&lt;img src="http://weblogs.sqlteam.com/mladenp/aggbug/60976.aspx" width="1" height="1" /&gt;
&lt;p&gt;&lt;a href="http://feedads.g.doubleclick.net/~a/ClCM6vDAI3CR_FgDFV7-nMfDtoE/0/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/ClCM6vDAI3CR_FgDFV7-nMfDtoE/0/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;br/&gt;
&lt;a href="http://feedads.g.doubleclick.net/~a/ClCM6vDAI3CR_FgDFV7-nMfDtoE/1/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/ClCM6vDAI3CR_FgDFV7-nMfDtoE/1/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;/p&gt;</description>
            <dc:creator>Mladen Prajdić</dc:creator>
            <guid isPermaLink="false">http://weblogs.sqlteam.com/mladenp/archive/2009/08/05/The-24-hours-of-PASS.aspx</guid>
            <pubDate>Wed, 05 Aug 2009 11:52:48 GMT</pubDate>
            <wfw:comment>http://weblogs.sqlteam.com/mladenp/comments/60976.aspx</wfw:comment>
            <comments>http://weblogs.sqlteam.com/mladenp/archive/2009/08/05/The-24-hours-of-PASS.aspx#feedback</comments>
            <wfw:commentRss>http://weblogs.sqlteam.com/mladenp/comments/commentRss/60976.aspx</wfw:commentRss>
            <trackback:ping>http://weblogs.sqlteam.com/mladenp/services/trackbacks/60976.aspx</trackback:ping>
        <feedburner:origLink>http://weblogs.sqlteam.com/mladenp/archive/2009/08/05/The-24-hours-of-PASS.aspx</feedburner:origLink></item>
        <item>
            <title>SQL Server 2005 &amp;ndash; Fast Running Totals solution with ordered CTE update?</title>
            <link>http://feedproxy.google.com/~r/mladenp/~3/kI9aQMLA2Bo/SQL-Server-2005-Fast-Running-Totals.aspx</link>
            <description>&lt;div&gt;&lt;span class="kwrd"&gt;The Running Totals problem is as old as accounting. In SQL Server there are different ways of calculating it and the general consensus is that it is one of the few problems best handled with a cursor. &lt;/span&gt;&lt;span class="kwrd"&gt;I still say it’s best handled in the presentation layer though. &lt;/span&gt;&lt;span class="kwrd"&gt;Being the SQL geek I am I can’t accept a problem in SQL S&lt;/span&gt;&lt;span class="kwrd"&gt;erver which has a cursor for a solution (just kidding).&lt;/span&gt;&lt;/div&gt;  &lt;div&gt;&lt;span class="kwrd"&gt;&lt;/span&gt;&lt;/div&gt;  &lt;div&gt;&lt;span class="kwrd"&gt;&lt;/span&gt;&lt;/div&gt;  &lt;div&gt;&lt;span class="kwrd"&gt;Note that I didn’t put any indexes on the tables so we can’t rely on them for any kind of ordering. The base table has 10 million rows and we’re going to aggregate on a 1 million row subset. For shortness sake the &lt;/span&gt;&lt;span class="kwrd"&gt;test table consists of a single column that we will aggregate on. &lt;/span&gt;&lt;span class="kwrd"&gt;And if you really need to output running totals of 1 million rows on the fly you’re doing something wrong. :)&lt;/span&gt;&lt;/div&gt;  &lt;div&gt;&lt;span class="kwrd"&gt;&lt;/span&gt; &lt;/div&gt;  &lt;div&gt;&lt;span class="kwrd"&gt;&lt;/span&gt;&lt;/div&gt;  &lt;div&gt;   &lt;pre class="csharpcode"&gt;&lt;span class="kwrd"&gt;IF&lt;/span&gt; OBJECT_ID(&lt;span class="str"&gt;'tempdb..#baseTable'&lt;/span&gt;) &lt;span class="kwrd"&gt;IS&lt;/span&gt; &lt;span class="kwrd"&gt;NOT&lt;/span&gt; &lt;span class="kwrd"&gt;NULL&lt;/span&gt;
    &lt;span class="kwrd"&gt;DROP&lt;/span&gt; &lt;span class="kwrd"&gt;TABLE&lt;/span&gt; #baseTable
&lt;span class="rem"&gt;-- create a 10 million row base table&lt;/span&gt;
&lt;span class="rem"&gt;-- we need running totals for 1 million rows out of 10 million&lt;/span&gt;
&lt;span class="kwrd"&gt;SELECT&lt;/span&gt; &lt;span class="kwrd"&gt;TOP&lt;/span&gt; 10000000 &lt;span class="rem"&gt;-- 10 million row table&lt;/span&gt;
       ROW_NUMBER() &lt;span class="kwrd"&gt;OVER&lt;/span&gt; (&lt;span class="kwrd"&gt;ORDER&lt;/span&gt; &lt;span class="kwrd"&gt;BY&lt;/span&gt; t1.Number) &lt;span class="kwrd"&gt;AS&lt;/span&gt; Number
&lt;span class="kwrd"&gt;INTO&lt;/span&gt;   #baseTable
&lt;span class="kwrd"&gt;FROM&lt;/span&gt;   master..spt_values t1
       &lt;span class="kwrd"&gt;CROSS&lt;/span&gt; &lt;span class="kwrd"&gt;JOIN&lt;/span&gt; master..spt_values t2
       &lt;span class="kwrd"&gt;CROSS&lt;/span&gt; &lt;span class="kwrd"&gt;JOIN&lt;/span&gt; master..spt_values t3&lt;/pre&gt;
&lt;/div&gt;

&lt;h4&gt;&lt;span class="kwrd"&gt;The ordered CTE Update solution&lt;/span&gt;&lt;/h4&gt;

&lt;p&gt;In SQL Server 2005 &lt;a href="http://msdn.microsoft.com/en-us/library/ms190766.aspx" target="_blank"&gt;&lt;strong&gt;&lt;font color="#004080"&gt;Common Table Expressions&lt;/font&gt;&lt;/strong&gt;&lt;/a&gt; (CTE) were introduced. They work like a view inside your select statement. What is cool and not well known about them is that you can update, insert and delete their results without joining them to other tables. I used a TOP (Int Max value) trick because the TOP 100 Percent syntax is &lt;strong&gt;&lt;a href="http://blogs.msdn.com/queryoptteam/archive/2006/03/24/560396.aspx" target="_blank"&gt;&lt;font color="#004080"&gt;considered harmful&lt;/font&gt;&lt;/a&gt;&lt;/strong&gt;. Because of this I didn’t want to rely on it.&lt;/p&gt;

&lt;p&gt;The next gem is the &lt;a href="http://msdn.microsoft.com/en-us/library/ms177564.aspx" target="_blank"&gt;&lt;strong&gt;&lt;font color="#004080"&gt;OUTPUT&lt;/font&gt;&lt;/strong&gt;&lt;/a&gt; clause which was also introduced in SQL Server 2005. It outputs changed data from an update, delete or an insert statement into a result set so you don’t need to do another select. &lt;/p&gt;

&lt;p&gt;First we populate the temp table with the 1 million rows subset we wish and add an extra RT column which will hold the Running total value. Next we create an ordered CTE, update it with “the direct variable and column update at the same time” trick and directly output the updated rows into the returning result set.&lt;/p&gt;

&lt;div&gt;
  &lt;pre class="csharpcode"&gt;&lt;span class="kwrd"&gt;IF&lt;/span&gt; OBJECT_ID(&lt;span class="str"&gt;'tempdb..#testCTE'&lt;/span&gt;) &lt;span class="kwrd"&gt;IS&lt;/span&gt; &lt;span class="kwrd"&gt;NOT&lt;/span&gt; &lt;span class="kwrd"&gt;NULL&lt;/span&gt;
    &lt;span class="kwrd"&gt;DROP&lt;/span&gt; &lt;span class="kwrd"&gt;TABLE&lt;/span&gt; #testCTE

&lt;span class="kwrd"&gt;DECLARE&lt;/span&gt; @dtStart DATETIME
&lt;span class="kwrd"&gt;SELECT&lt;/span&gt;  @dtStart = GETDATE()

&lt;span class="rem"&gt;-- create our temp table to return data from&lt;/span&gt;
&lt;span class="kwrd"&gt;SELECT&lt;/span&gt; &lt;span class="kwrd"&gt;TOP&lt;/span&gt; 1000000 Number, &lt;span class="kwrd"&gt;CAST&lt;/span&gt;(0 &lt;span class="kwrd"&gt;AS&lt;/span&gt; BIGINT) RT
&lt;span class="kwrd"&gt;INTO&lt;/span&gt;   #testCTE
&lt;span class="kwrd"&gt;FROM&lt;/span&gt;   #baseTable
&lt;span class="kwrd"&gt;ORDER&lt;/span&gt; &lt;span class="kwrd"&gt;BY&lt;/span&gt; Number&lt;/pre&gt;

  &lt;pre class="csharpcode"&gt;&lt;span class="rem"&gt;-- ORDER BY NEWID() -- also works just fine&lt;/span&gt;

&lt;span class="rem"&gt;-- declare helper variable&lt;/span&gt;
&lt;span class="kwrd"&gt;DECLARE&lt;/span&gt; @RT BIGINT
&lt;span class="kwrd"&gt;SELECT&lt;/span&gt; @RT = 0

;&lt;span class="kwrd"&gt;WITH&lt;/span&gt; RunningTotals &lt;span class="kwrd"&gt;AS&lt;/span&gt;
(
    &lt;span class="kwrd"&gt;SELECT&lt;/span&gt; &lt;span class="kwrd"&gt;TOP&lt;/span&gt; (2147483647) &lt;span class="rem"&gt;-- put a int max value here to get all rows&lt;/span&gt;
           Number, RT
    &lt;span class="kwrd"&gt;FROM&lt;/span&gt;   #testCTE
    &lt;span class="kwrd"&gt;ORDER&lt;/span&gt; &lt;span class="kwrd"&gt;BY&lt;/span&gt; Number
    &lt;span class="rem"&gt;-- both of there work correctly&lt;/span&gt;
    &lt;span class="rem"&gt;-- ORDER BY Number DESC&lt;/span&gt;
    &lt;span class="rem"&gt;-- ORDER BY NEWID()&lt;/span&gt;
)
&lt;span class="kwrd"&gt;UPDATE&lt;/span&gt; RunningTotals 
&lt;span class="kwrd"&gt;SET&lt;/span&gt;       @RT = RT = @RT + Number
&lt;span class="kwrd"&gt;OUTPUT&lt;/span&gt; inserted.*

&lt;span class="kwrd"&gt;SELECT&lt;/span&gt; DATEDIFF(s, @dtStart, GETDATE()) &lt;span class="kwrd"&gt;AS&lt;/span&gt; DurationInSeconds&lt;/pre&gt;
&lt;/div&gt;

&lt;p&gt; &lt;/p&gt;

&lt;p&gt;The query ran in 8 seconds which blew my mind. I tried various orderings of the column, putting &lt;strike&gt;clustered and &lt;/strike&gt;nonclustered indexes, ordering insert into #testCTE table by newid() but I couldn’t find any example where the ordering would not be honored. Even fragmenting the index didn’t break it.&lt;/p&gt;

&lt;p&gt;If anyone could provide an example when the order by isn’t honored I’d be very pleased. Being proved wrong is kind of fun :)&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;font color="#ff0000"&gt;UPDATE: &lt;/font&gt;&lt;/strong&gt;&lt;strong&gt;Problems with clustered index&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;After playing some more and discussing this with &lt;a href="http://www.sqlservercentral.com/Authors/Articles/Jeff_Moden/80567/" target="_blank"&gt;&lt;strong&gt;&lt;font color="#004080"&gt;Jeff Moden&lt;/font&gt;&lt;/strong&gt;&lt;/a&gt; (hoped he would drop in :)) the problem with adding a clustered index is that the clustered index is always updated in the order of the clustering key. It doesn’t matter on which column it is. We can verify this easily by doing this:&lt;/p&gt;

&lt;div&gt;
  &lt;pre class="csharpcode"&gt;&lt;span class="kwrd"&gt;SELECT&lt;/span&gt; &lt;span class="kwrd"&gt;TOP&lt;/span&gt; 1000000 Number, &lt;span class="kwrd"&gt;CAST&lt;/span&gt;(0 &lt;span class="kwrd"&gt;AS&lt;/span&gt; BIGINT) RT
&lt;span class="kwrd"&gt;INTO&lt;/span&gt;   #testCTE
&lt;span class="kwrd"&gt;FROM&lt;/span&gt;   #baseTable
&lt;span class="kwrd"&gt;ORDER&lt;/span&gt; &lt;span class="kwrd"&gt;BY&lt;/span&gt; Number

&lt;span class="kwrd"&gt;CREATE&lt;/span&gt; &lt;span class="kwrd"&gt;CLUSTERED&lt;/span&gt; &lt;span class="kwrd"&gt;INDEX&lt;/span&gt; CI_testCTE_Number &lt;span class="kwrd"&gt;ON&lt;/span&gt; #testCTE(Number)&lt;/pre&gt;
&lt;/div&gt;

&lt;p&gt; &lt;/p&gt;

&lt;p&gt;If we run the upper CTE after adding a clustered index we can see that different ordering inside the CTE makes no difference since the update runs in the order of the clustering key. For this to work the #testCTE &lt;strong&gt;should NOT &lt;/strong&gt;have a clustered index on it. Non clustered indexes are ok and they make no difference since the ordering inside the CTE is respected.&lt;/p&gt;

&lt;p&gt;And please leave the running totals for the client to do. It’s its job. :)&lt;/p&gt;

&lt;h4&gt;&lt;span class="kwrd"&gt;The Cursor and &lt;span class="kwrd"&gt;Correlated subquery solutions&lt;/span&gt;&lt;/span&gt;&lt;/h4&gt;

&lt;p&gt;For completeness sake here are the cursor and correlated subquery solutions. Cursor solution took 48 seconds and I just killed the correlated subquery after 5 minutes.&lt;/p&gt;

&lt;div&gt;
  &lt;pre class="csharpcode"&gt;&lt;span class="rem"&gt;-- Cursor solution&lt;/span&gt;
&lt;span class="kwrd"&gt;IF&lt;/span&gt; OBJECT_ID(&lt;span class="str"&gt;'tempdb..#testCursor'&lt;/span&gt;) &lt;span class="kwrd"&gt;IS&lt;/span&gt; &lt;span class="kwrd"&gt;NOT&lt;/span&gt; &lt;span class="kwrd"&gt;NULL&lt;/span&gt;
    &lt;span class="kwrd"&gt;DROP&lt;/span&gt; &lt;span class="kwrd"&gt;TABLE&lt;/span&gt; #testCursor
&lt;span class="rem"&gt;-- create our empty temp table to return data from&lt;/span&gt;
&lt;span class="kwrd"&gt;DECLARE&lt;/span&gt; @dtStart DATETIME
&lt;span class="kwrd"&gt;SELECT&lt;/span&gt;  @dtStart = GETDATE()

&lt;span class="kwrd"&gt;SELECT&lt;/span&gt; &lt;span class="kwrd"&gt;TOP&lt;/span&gt; 1 Number, &lt;span class="kwrd"&gt;CAST&lt;/span&gt;(0 &lt;span class="kwrd"&gt;AS&lt;/span&gt; BIGINT) RT
&lt;span class="kwrd"&gt;INTO&lt;/span&gt;   #testCursor
&lt;span class="kwrd"&gt;FROM&lt;/span&gt;   #baseTable
&lt;span class="kwrd"&gt;WHERE&lt;/span&gt;  1=0

&lt;span class="kwrd"&gt;DECLARE&lt;/span&gt; RTCursor &lt;span class="kwrd"&gt;CURSOR&lt;/span&gt; &lt;span class="kwrd"&gt;FOR&lt;/span&gt; 
&lt;span class="kwrd"&gt;SELECT&lt;/span&gt; &lt;span class="kwrd"&gt;TOP&lt;/span&gt; 1000000 Number &lt;span class="kwrd"&gt;FROM&lt;/span&gt; #baseTable &lt;span class="kwrd"&gt;ORDER&lt;/span&gt; &lt;span class="kwrd"&gt;BY&lt;/span&gt; Number

&lt;span class="kwrd"&gt;DECLARE&lt;/span&gt; @Number &lt;span class="kwrd"&gt;INT&lt;/span&gt;, @RT BIGINT
&lt;span class="kwrd"&gt;SELECT&lt;/span&gt; @RT = 0

&lt;span class="kwrd"&gt;OPEN&lt;/span&gt; RTCursor
&lt;span class="kwrd"&gt;WHILE&lt;/span&gt; (0=0) &lt;span class="kwrd"&gt;BEGIN&lt;/span&gt; 
    &lt;span class="kwrd"&gt;FETCH&lt;/span&gt; &lt;span class="kwrd"&gt;NEXT&lt;/span&gt; &lt;span class="kwrd"&gt;FROM&lt;/span&gt; RTCursor &lt;span class="kwrd"&gt;INTO&lt;/span&gt; @Number
    
    &lt;span class="kwrd"&gt;IF&lt;/span&gt; &lt;span class="preproc"&gt;@@FETCH_STATUS&lt;/span&gt; &amp;lt;&amp;gt; 0 &lt;span class="kwrd"&gt;BREAK&lt;/span&gt; 
  
    &lt;span class="kwrd"&gt;SET&lt;/span&gt; @RT = @RT + @Number
  
    INSERT &lt;span class="kwrd"&gt;INTO&lt;/span&gt; #testCursor(Number, RT) 
    &lt;span class="kwrd"&gt;VALUES&lt;/span&gt;(@Number, @RT ) 
&lt;span class="kwrd"&gt;END&lt;/span&gt;
&lt;span class="kwrd"&gt;CLOSE&lt;/span&gt; RTCursor
&lt;span class="kwrd"&gt;DEALLOCATE&lt;/span&gt; RTCursor

&lt;span class="kwrd"&gt;SELECT&lt;/span&gt; *
&lt;span class="kwrd"&gt;FROM&lt;/span&gt; #testCursor
&lt;span class="kwrd"&gt;ORDER&lt;/span&gt; &lt;span class="kwrd"&gt;BY&lt;/span&gt; Number

&lt;span class="kwrd"&gt;SELECT&lt;/span&gt; DATEDIFF(s, @dtStart, GETDATE()) &lt;span class="kwrd"&gt;AS&lt;/span&gt; DurationInSeconds
&lt;span class="kwrd"&gt;GO&lt;/span&gt;

&lt;span class="rem"&gt;-- Correlated subquery method&lt;/span&gt;
&lt;span class="kwrd"&gt;SELECT&lt;/span&gt; &lt;span class="kwrd"&gt;TOP&lt;/span&gt; 1000 Number, (&lt;span class="kwrd"&gt;SELECT&lt;/span&gt; &lt;span class="kwrd"&gt;SUM&lt;/span&gt;(Number) &lt;span class="kwrd"&gt;FROM&lt;/span&gt; #baseTable &lt;span class="kwrd"&gt;WHERE&lt;/span&gt; Number &amp;lt;= t1.Number) &lt;span class="kwrd"&gt;AS&lt;/span&gt; RT
&lt;span class="kwrd"&gt;FROM&lt;/span&gt;   #baseTable t1
&lt;span class="kwrd"&gt;ORDER&lt;/span&gt; &lt;span class="kwrd"&gt;BY&lt;/span&gt; Number&lt;/pre&gt;
&lt;/div&gt;

&lt;p&gt; &lt;/p&gt;

&lt;p&gt; &lt;/p&gt;

&lt;p&gt;I haven’t tried the SQL CLR solution for this so if anyone has any benchmarks I’d be glad to hear them.&lt;/p&gt;
&lt;a href="http://www.dotnetkicks.com/kick/?url=http%3a%2f%2fweblogs.sqlteam.com%2fmladenp%2farchive%2f2009%2f07%2f28%2fSQL-Server-2005-Fast-Running-Totals.aspx"&gt;&lt;img border="0" alt="kick it on DotNetKicks.com" src="http://www.dotnetkicks.com/Services/Images/KickItImageGenerator.ashx?url=http%3a%2f%2fweblogs.sqlteam.com%2fmladenp%2farchive%2f2009%2f07%2f28%2fSQL-Server-2005-Fast-Running-Totals.aspx" /&gt;&lt;/a&gt;&lt;img src="http://weblogs.sqlteam.com/mladenp/aggbug/60971.aspx" width="1" height="1" /&gt;
&lt;p&gt;&lt;a href="http://feedads.g.doubleclick.net/~a/8LlCqY5Cow98ZTiNFvK0aEanAB0/0/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/8LlCqY5Cow98ZTiNFvK0aEanAB0/0/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;br/&gt;
&lt;a href="http://feedads.g.doubleclick.net/~a/8LlCqY5Cow98ZTiNFvK0aEanAB0/1/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/8LlCqY5Cow98ZTiNFvK0aEanAB0/1/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;/p&gt;</description>
            <dc:creator>Mladen Prajdić</dc:creator>
            <guid isPermaLink="false">http://weblogs.sqlteam.com/mladenp/archive/2009/07/28/SQL-Server-2005-Fast-Running-Totals.aspx</guid>
            <pubDate>Tue, 28 Jul 2009 09:48:29 GMT</pubDate>
            <wfw:comment>http://weblogs.sqlteam.com/mladenp/comments/60971.aspx</wfw:comment>
            <comments>http://weblogs.sqlteam.com/mladenp/archive/2009/07/28/SQL-Server-2005-Fast-Running-Totals.aspx#feedback</comments>
            <slash:comments>15</slash:comments>
            <wfw:commentRss>http://weblogs.sqlteam.com/mladenp/comments/commentRss/60971.aspx</wfw:commentRss>
            <trackback:ping>http://weblogs.sqlteam.com/mladenp/services/trackbacks/60971.aspx</trackback:ping>
        <feedburner:origLink>http://weblogs.sqlteam.com/mladenp/archive/2009/07/28/SQL-Server-2005-Fast-Running-Totals.aspx</feedburner:origLink></item>
        <item>
            <title>How to check when was SQL Server installed with a T-SQL query</title>
            <link>http://feedproxy.google.com/~r/mladenp/~3/VMCLiZefAZA/How-to-check-when-was-SQL-Server-installed-with-a.aspx</link>
            <description>&lt;p&gt;Today on twitter Lori Edwards (&lt;a href="http://twitter.com/loriedwards/" target="_blank"&gt;&lt;strong&gt;&lt;font color="#004080"&gt;@loriedwards&lt;/font&gt;&lt;/strong&gt;&lt;/a&gt;) asked how can you check when was SQL Server installed with a T-SQL query. Otherwise this is pretty simple by looking at the creation time of master database (provided you never had to restore it).&lt;/p&gt;  &lt;p&gt;But i wanted to find a nice way of doing this without resorting to any xp_ stored procedures. Of course this is possible by looking into the &lt;a href="http://msdn.microsoft.com/en-us/library/ms178593(SQL.90).aspx" target="_blank"&gt;&lt;strong&gt;&lt;font color="#004080"&gt;sys.syslogins&lt;/font&gt;&lt;/strong&gt;&lt;/a&gt; compatibility view:&lt;/p&gt;  &lt;div&gt;   &lt;pre class="csharpcode"&gt;&lt;span class="kwrd"&gt;SELECT&lt;/span&gt;  createdate &lt;span class="kwrd"&gt;as&lt;/span&gt; Sql_Server_Install_Date 
&lt;span class="kwrd"&gt;FROM&lt;/span&gt;    sys.syslogins 
&lt;span class="kwrd"&gt;where&lt;/span&gt;   sid = 0x010100000000000512000000 &lt;span class="rem"&gt;-- language neutral&lt;/span&gt;
        &lt;span class="rem"&gt;-- loginname = 'NT AUTHORITY\SYSTEM' -- only English language installations&lt;/span&gt;&lt;/pre&gt;
&lt;/div&gt;

&lt;p&gt; &lt;/p&gt;

&lt;p&gt;This query actually returns the creation date and time of the NT AUTHORITY\SYSTEM login which gets created when you install SQL Server. This of course won’t work if you had to restore the master database.&lt;/p&gt;

&lt;p&gt;Pretty simple if you know where to look :))&lt;/p&gt;

&lt;p&gt; &lt;/p&gt;
&lt;a href="http://www.dotnetkicks.com/kick/?url=http%3a%2f%2fweblogs.sqlteam.com%2fmladenp%2farchive%2f2009%2f07%2f16%2fHow-to-check-when-was-SQL-Server-installed-with-a.aspx"&gt;&lt;img border="0" alt="kick it on DotNetKicks.com" src="http://www.dotnetkicks.com/Services/Images/KickItImageGenerator.ashx?url=http%3a%2f%2fweblogs.sqlteam.com%2fmladenp%2farchive%2f2009%2f07%2f16%2fHow-to-check-when-was-SQL-Server-installed-with-a.aspx" /&gt;&lt;/a&gt;&lt;img src="http://weblogs.sqlteam.com/mladenp/aggbug/60961.aspx" width="1" height="1" /&gt;
&lt;p&gt;&lt;a href="http://feedads.g.doubleclick.net/~a/C6ySaPOnfG-p2emDZREkHB_plnQ/0/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/C6ySaPOnfG-p2emDZREkHB_plnQ/0/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;br/&gt;
&lt;a href="http://feedads.g.doubleclick.net/~a/C6ySaPOnfG-p2emDZREkHB_plnQ/1/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/C6ySaPOnfG-p2emDZREkHB_plnQ/1/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;/p&gt;</description>
            <dc:creator>Mladen Prajdić</dc:creator>
            <guid isPermaLink="false">http://weblogs.sqlteam.com/mladenp/archive/2009/07/16/How-to-check-when-was-SQL-Server-installed-with-a.aspx</guid>
            <pubDate>Thu, 16 Jul 2009 16:55:19 GMT</pubDate>
            <wfw:comment>http://weblogs.sqlteam.com/mladenp/comments/60961.aspx</wfw:comment>
            <comments>http://weblogs.sqlteam.com/mladenp/archive/2009/07/16/How-to-check-when-was-SQL-Server-installed-with-a.aspx#feedback</comments>
            <slash:comments>4</slash:comments>
            <wfw:commentRss>http://weblogs.sqlteam.com/mladenp/comments/commentRss/60961.aspx</wfw:commentRss>
            <trackback:ping>http://weblogs.sqlteam.com/mladenp/services/trackbacks/60961.aspx</trackback:ping>
        <feedburner:origLink>http://weblogs.sqlteam.com/mladenp/archive/2009/07/16/How-to-check-when-was-SQL-Server-installed-with-a.aspx</feedburner:origLink></item>
        <item>
            <title>SQL Server 2008 for Developers live meeting presentation</title>
            <link>http://feedproxy.google.com/~r/mladenp/~3/jCA4awHiFoM/SQL-Server-2008-for-Developers-live-meeting-presentation.aspx</link>
            <description>&lt;p&gt;I’ll be talking about the following topics:&lt;/p&gt;  &lt;li&gt;What should developers know about database design so they don't have performance and logical problems? &lt;/li&gt;  &lt;li&gt;What's new in SQL Server 2008 that helps solve some business problems that sometime required "hacking" before. &lt;/li&gt;  &lt;li&gt;Concurrency design models and isolation levels.    &lt;p&gt; &lt;/p&gt;    &lt;p&gt;The presentation will start on Tuesday June 16th at 2:00 PM EST / 6:00 PM UTC / 8:00 PM CET&lt;/p&gt;    &lt;p&gt;More info at &lt;a href="http://www.sqlpass.org/Community/SIGs/ApplicationDevelopmentSIG/tabid/81/Default.aspx" target="_blank"&gt;&lt;strong&gt;&lt;font color="#004080"&gt;PASS Application Development SIG&lt;/font&gt;&lt;/strong&gt;&lt;/a&gt;&lt;/p&gt; &lt;/li&gt;  &lt;p&gt; &lt;/p&gt;  &lt;p&gt;&lt;strong&gt;UPDATE:&lt;/strong&gt; you can view the presentation &lt;a href="http://www.sqlpass.org/Community/SIGs/ApplicationDevelopmentSIG/AppDevLiveMeetingRecordings.aspx" target="_blank"&gt;&lt;strong&gt;&lt;font color="#004080"&gt;here&lt;/font&gt;&lt;/strong&gt;&lt;/a&gt;.&lt;/p&gt;&lt;img src="http://weblogs.sqlteam.com/mladenp/aggbug/60934.aspx" width="1" height="1" /&gt;
&lt;p&gt;&lt;a href="http://feedads.g.doubleclick.net/~a/rBuw1kGV5J5rnRk1tJwv5YnYqus/0/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/rBuw1kGV5J5rnRk1tJwv5YnYqus/0/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;br/&gt;
&lt;a href="http://feedads.g.doubleclick.net/~a/rBuw1kGV5J5rnRk1tJwv5YnYqus/1/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/rBuw1kGV5J5rnRk1tJwv5YnYqus/1/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;/p&gt;</description>
            <dc:creator>Mladen Prajdić</dc:creator>
            <guid isPermaLink="false">http://weblogs.sqlteam.com/mladenp/archive/2009/06/15/SQL-Server-2008-for-Developers-live-meeting-presentation.aspx</guid>
            <pubDate>Mon, 15 Jun 2009 21:22:56 GMT</pubDate>
            <wfw:comment>http://weblogs.sqlteam.com/mladenp/comments/60934.aspx</wfw:comment>
            <comments>http://weblogs.sqlteam.com/mladenp/archive/2009/06/15/SQL-Server-2008-for-Developers-live-meeting-presentation.aspx#feedback</comments>
            <wfw:commentRss>http://weblogs.sqlteam.com/mladenp/comments/commentRss/60934.aspx</wfw:commentRss>
            <trackback:ping>http://weblogs.sqlteam.com/mladenp/services/trackbacks/60934.aspx</trackback:ping>
        <feedburner:origLink>http://weblogs.sqlteam.com/mladenp/archive/2009/06/15/SQL-Server-2008-for-Developers-live-meeting-presentation.aspx</feedburner:origLink></item>
        <item>
            <title>Adding one file to multiple projects in a .Net solution</title>
            <link>http://feedproxy.google.com/~r/mladenp/~3/cXjnSLaHyxY/Adding-one-file-to-multiple-projects-in-a-.Net-solution.aspx</link>
            <description>&lt;p&gt;There are times when you want to have one .cs file in multiple projects. However if you do Add existing item you’ll notice that the file is copied to each project’s folder. This is not what we want.&lt;/p&gt;
&lt;p&gt;The solutions is of course pretty simple once you know where to look. In the Add existing item dialog you have to add the file as a Link as is shown on the picture:&lt;/p&gt;
&lt;p&gt; &lt;/p&gt;
&lt;p&gt;&lt;a href="http://weblogs.sqlteam.com/images/weblogs_sqlteam_com/mladenp/WindowsLiveWriter/Addingone.CSfiletomultiplepr.Netsolution_E0D8/AddCommonItem_2.png"&gt;&lt;img style="BORDER-RIGHT-WIDTH: 0px; DISPLAY: inline; BORDER-TOP-WIDTH: 0px; BORDER-BOTTOM-WIDTH: 0px; BORDER-LEFT-WIDTH: 0px" title="AddCommonItem" border="0" alt="AddCommonItem" width="571" height="521" src="http://weblogs.sqlteam.com/images/weblogs_sqlteam_com/mladenp/WindowsLiveWriter/Addingone.CSfiletomultiplepr.Netsolution_E0D8/AddCommonItem_thumb.png" /&gt;&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;And there you go. you can have one file in multiple projects.&lt;/p&gt;
&lt;a href="http://www.dotnetkicks.com/kick/?url=http%3a%2f%2fweblogs.sqlteam.com%2fmladenp%2farchive%2f2009%2f06%2f05%2fAdding-one-file-to-multiple-projects-in-a-.Net-solution.aspx"&gt;&lt;img border="0" alt="kick it on DotNetKicks.com" src="http://www.dotnetkicks.com/Services/Images/KickItImageGenerator.ashx?url=http%3a%2f%2fweblogs.sqlteam.com%2fmladenp%2farchive%2f2009%2f06%2f05%2fAdding-one-file-to-multiple-projects-in-a-.Net-solution.aspx" /&gt;&lt;/a&gt;&lt;img src="http://weblogs.sqlteam.com/mladenp/aggbug/60926.aspx" width="1" height="1" /&gt;
&lt;p&gt;&lt;a href="http://feedads.g.doubleclick.net/~a/A8jlfuSHU0hq1U4rkQLDWGbLyJ4/0/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/A8jlfuSHU0hq1U4rkQLDWGbLyJ4/0/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;br/&gt;
&lt;a href="http://feedads.g.doubleclick.net/~a/A8jlfuSHU0hq1U4rkQLDWGbLyJ4/1/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/A8jlfuSHU0hq1U4rkQLDWGbLyJ4/1/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;/p&gt;</description>
            <dc:creator>Mladen Prajdić</dc:creator>
            <guid isPermaLink="false">http://weblogs.sqlteam.com/mladenp/archive/2009/06/05/Adding-one-file-to-multiple-projects-in-a-.Net-solution.aspx</guid>
            <pubDate>Fri, 05 Jun 2009 14:03:44 GMT</pubDate>
            <wfw:comment>http://weblogs.sqlteam.com/mladenp/comments/60926.aspx</wfw:comment>
            <comments>http://weblogs.sqlteam.com/mladenp/archive/2009/06/05/Adding-one-file-to-multiple-projects-in-a-.Net-solution.aspx#feedback</comments>
            <slash:comments>2</slash:comments>
            <wfw:commentRss>http://weblogs.sqlteam.com/mladenp/comments/commentRss/60926.aspx</wfw:commentRss>
            <trackback:ping>http://weblogs.sqlteam.com/mladenp/services/trackbacks/60926.aspx</trackback:ping>
        <feedburner:origLink>http://weblogs.sqlteam.com/mladenp/archive/2009/06/05/Adding-one-file-to-multiple-projects-in-a-.Net-solution.aspx</feedburner:origLink></item>
        <item>
            <title>SQL Server 2008 Extended Events - high performance eventing system</title>
            <link>http://feedproxy.google.com/~r/mladenp/~3/EFU3fkt6MOw/SQL-Server-2008-Extended-Events---high-performance-eventing-system.aspx</link>
            <description>&lt;p&gt;I’ve written two articles on &lt;a href="http://www.sqlteam.com" target="_blank"&gt;&lt;strong&gt;&lt;font color="#004080"&gt;SQLTeam.com&lt;/font&gt;&lt;/strong&gt;&lt;/a&gt; about a great new feature in SQL Server 2008 called Extended Events. They are the new low level, high performance eventing system in SQL Server. They use less system resources and provide better tracking of SQL Server performance than previous methods like Perfmon and SQL Trace/Profiler events.&lt;/p&gt;  &lt;p&gt; &lt;/p&gt;  &lt;p&gt;1. &lt;a href="http://www.sqlteam.com/article/introduction-to-sql-server-2008-extended-events" target="_blank"&gt;&lt;strong&gt;&lt;font color="#004080"&gt;Introduction to SQL Server 2008 Extended Events&lt;/font&gt;&lt;/strong&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;This is an introductory article where we take a look at performance troubleshooting and system monitoring and what they lack in previous SQL Server versions. After that we get to know the Extended Events architecture, new terminology and we try them out with a simple example.&lt;/p&gt;  &lt;p&gt; &lt;/p&gt;  &lt;p&gt;2. &lt;a href="http://www.sqlteam.com/article/advanced-sql-server-2008-extended-events-with-examples" target="_blank"&gt;&lt;strong&gt;&lt;font color="#004080"&gt;Advanced SQL Server 2008 Extended Events with Examples&lt;/font&gt;&lt;/strong&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;Part 2 of the series takes a look at some performance considerations we must be aware of when using Extended Events like synchronous or asynchronous target target, predicate short circuiting and event action size. After we take a look at 7 examples that show a different way we can use them to troubleshoot our system. Examples are meant to show Extended Events power and give some ideas on how to use them for more advanced monitoring.&lt;/p&gt;  &lt;p&gt; &lt;/p&gt;  &lt;p&gt;&lt;a href="http://www.dotnetkicks.com/kick/?url=http%3a%2f%2fweblogs.sqlteam.com%2fmladenp%2farchive%2f2009%2f05%2f29%2fSQL-Server-2008-Extended-Events---high-performance-eventing-system.aspx"&gt;&lt;img border="0" alt="kick it on DotNetKicks.com" src="http://www.dotnetkicks.com/Services/Images/KickItImageGenerator.ashx?url=http%3a%2f%2fweblogs.sqlteam.com%2fmladenp%2farchive%2f2009%2f05%2f29%2fSQL-Server-2008-Extended-Events---high-performance-eventing-system.aspx" /&gt;&lt;/a&gt;&lt;/p&gt;&lt;img src="http://weblogs.sqlteam.com/mladenp/aggbug/60920.aspx" width="1" height="1" /&gt;
&lt;p&gt;&lt;a href="http://feedads.g.doubleclick.net/~a/d43lmlq_S9X45w8KQy43zuSnkac/0/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/d43lmlq_S9X45w8KQy43zuSnkac/0/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;br/&gt;
&lt;a href="http://feedads.g.doubleclick.net/~a/d43lmlq_S9X45w8KQy43zuSnkac/1/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/d43lmlq_S9X45w8KQy43zuSnkac/1/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;/p&gt;</description>
            <dc:creator>Mladen Prajdić</dc:creator>
            <guid isPermaLink="false">http://weblogs.sqlteam.com/mladenp/archive/2009/05/29/SQL-Server-2008-Extended-Events---high-performance-eventing-system.aspx</guid>
            <pubDate>Fri, 29 May 2009 14:15:36 GMT</pubDate>
            <wfw:comment>http://weblogs.sqlteam.com/mladenp/comments/60920.aspx</wfw:comment>
            <comments>http://weblogs.sqlteam.com/mladenp/archive/2009/05/29/SQL-Server-2008-Extended-Events---high-performance-eventing-system.aspx#feedback</comments>
            <wfw:commentRss>http://weblogs.sqlteam.com/mladenp/comments/commentRss/60920.aspx</wfw:commentRss>
            <trackback:ping>http://weblogs.sqlteam.com/mladenp/services/trackbacks/60920.aspx</trackback:ping>
        <feedburner:origLink>http://weblogs.sqlteam.com/mladenp/archive/2009/05/29/SQL-Server-2008-Extended-Events---high-performance-eventing-system.aspx</feedburner:origLink></item>
        <item>
            <title>Free SQL Server 2008 Powerpoint dark template</title>
            <link>http://feedproxy.google.com/~r/mladenp/~3/66ifLM2ACUM/Free-SQL-Server-2008-Powerpoint-dark-template.aspx</link>
            <description>&lt;p&gt;Recently i was looking for a SQL Server 2008 based template that would look cool. Since I haven’t found anything I’ve made my own. It’s a dark background template that you can use freely. &lt;/p&gt;
&lt;p&gt;Suggestions for improvements are welcome in the comments. Also if you have an idea for a light background based template, I’d love to hear it.&lt;/p&gt;
&lt;table border="0" cellspacing="2" cellpadding="0" width="834"&gt;
    &lt;tbody&gt;
        &lt;tr&gt;
            &lt;td valign="bottom" width="413" align="center"&gt;
            &lt;p&gt;&lt;strong&gt;&lt;font size="4"&gt;The title look&lt;/font&gt;&lt;/strong&gt;&lt;/p&gt;
            &lt;/td&gt;
            &lt;td valign="bottom" width="413" align="center"&gt;
            &lt;p&gt;&lt;strong&gt;&lt;font size="4"&gt;The slide look&lt;/font&gt;&lt;/strong&gt;&lt;/p&gt;
            &lt;/td&gt;
        &lt;/tr&gt;
        &lt;tr&gt;
            &lt;td valign="top" width="413" align="center"&gt;
            &lt;p align="left"&gt;&lt;a target="_blank" href="http://www.sqlteam.com/downloads/sqlserver2008_dark.zip"&gt;&lt;img style="BORDER-RIGHT-WIDTH: 0px; DISPLAY: block; FLOAT: none; BORDER-TOP-WIDTH: 0px; BORDER-BOTTOM-WIDTH: 0px; MARGIN-LEFT: auto; BORDER-LEFT-WIDTH: 0px; MARGIN-RIGHT: auto" title="Presentation_Dark_Title" border="0" alt="Presentation_Dark_Title" width="410" height="306" src="http://weblogs.sqlteam.com/images/weblogs_sqlteam_com/mladenp/WindowsLiveWriter/FreeSQLServer2008basedPowerpointtemplate_EEC1/Presentation_Dark_Title_3.png" /&gt;&lt;/a&gt;&lt;/p&gt;
            &lt;/td&gt;
            &lt;td valign="top" width="413" align="center"&gt;
            &lt;p align="left"&gt;&lt;a target="_blank" href="http://www.sqlteam.com/downloads/sqlserver2008_dark.zip"&gt;&lt;img style="BORDER-RIGHT-WIDTH: 0px; DISPLAY: block; FLOAT: none; BORDER-TOP-WIDTH: 0px; BORDER-BOTTOM-WIDTH: 0px; MARGIN-LEFT: auto; BORDER-LEFT-WIDTH: 0px; MARGIN-RIGHT: auto" title="Presentation_Dark_Slide" border="0" alt="Presentation_Dark_Slide" width="410" height="307" src="http://weblogs.sqlteam.com/images/weblogs_sqlteam_com/mladenp/WindowsLiveWriter/FreeSQLServer2008basedPowerpointtemplate_EEC1/Presentation_Dark_Slide_3.png" /&gt;&lt;/a&gt;&lt;/p&gt;
            &lt;/td&gt;
        &lt;/tr&gt;
    &lt;/tbody&gt;
&lt;/table&gt;
&lt;p&gt; &lt;/p&gt;
&lt;p&gt;Here you go: &lt;a target="_blank" href="http://www.sqlteam.com/downloads/sqlserver2008_dark.zip"&gt;&lt;strong&gt;&lt;font color="#004080"&gt;SQL Server 2008 Dark Template&lt;/font&gt;&lt;/strong&gt;&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;Enjoy it!&lt;/p&gt;
&lt;a href="http://www.dotnetkicks.com/kick/?url=http%3a%2f%2fweblogs.sqlteam.com%2fmladenp%2farchive%2f2009%2f05%2f07%2fFree-SQL-Server-2008-Powerpoint-dark-template.aspx"&gt;&lt;img border="0" alt="kick it on DotNetKicks.com" src="http://www.dotnetkicks.com/Services/Images/KickItImageGenerator.ashx?url=http%3a%2f%2fweblogs.sqlteam.com%2fmladenp%2farchive%2f2009%2f05%2f07%2fFree-SQL-Server-2008-Powerpoint-dark-template.aspx" /&gt;&lt;/a&gt;&lt;img src="http://weblogs.sqlteam.com/mladenp/aggbug/60906.aspx" width="1" height="1" /&gt;
&lt;p&gt;&lt;a href="http://feedads.g.doubleclick.net/~a/lL_PsZxJgtScj8dWGUsaQ01GGoI/0/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/lL_PsZxJgtScj8dWGUsaQ01GGoI/0/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;br/&gt;
&lt;a href="http://feedads.g.doubleclick.net/~a/lL_PsZxJgtScj8dWGUsaQ01GGoI/1/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/lL_PsZxJgtScj8dWGUsaQ01GGoI/1/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;/p&gt;</description>
            <dc:creator>Mladen Prajdić</dc:creator>
            <guid isPermaLink="false">http://weblogs.sqlteam.com/mladenp/archive/2009/05/07/Free-SQL-Server-2008-Powerpoint-dark-template.aspx</guid>
            <pubDate>Thu, 07 May 2009 11:24:51 GMT</pubDate>
            <wfw:comment>http://weblogs.sqlteam.com/mladenp/comments/60906.aspx</wfw:comment>
            <comments>http://weblogs.sqlteam.com/mladenp/archive/2009/05/07/Free-SQL-Server-2008-Powerpoint-dark-template.aspx#feedback</comments>
            <slash:comments>1</slash:comments>
            <wfw:commentRss>http://weblogs.sqlteam.com/mladenp/comments/commentRss/60906.aspx</wfw:commentRss>
            <trackback:ping>http://weblogs.sqlteam.com/mladenp/services/trackbacks/60906.aspx</trackback:ping>
        <feedburner:origLink>http://weblogs.sqlteam.com/mladenp/archive/2009/05/07/Free-SQL-Server-2008-Powerpoint-dark-template.aspx</feedburner:origLink></item>
        <item>
            <title>Comparing SQL Server HASHBYTES function and .Net hashing</title>
            <link>http://feedproxy.google.com/~r/mladenp/~3/7En-ZJ-drRc/Comparing-SQL-Server-HASHBYTES-function-and-.Net-hashing.aspx</link>
            <description>&lt;p&gt;&lt;span class="rem"&gt;A while back we had an interesting problem at work. We were calculating MD5 hashes for some values in both .Net and SQL Server and although the input values were all the same our MD5 hashes were different. After some time spent looking dumbfounded at the code I’ve realized what the bug was and started laughing. I saw that &lt;a target="_blank" href="http://msdn.microsoft.com/en-us/library/ms174415.aspx"&gt;&lt;strong&gt;&lt;font color="#004080"&gt;HashBytes&lt;/font&gt;&lt;/strong&gt;&lt;/a&gt; function was the “culprit”. HashBytes function was introduced in SQL server 2005 to simplify creating hashes in the database. It can convert values to MD2, MD4, MD5, SHA, or SHA1 formats. &lt;/span&gt;&lt;span class="rem"&gt;HashBytes' result depends on the input text’s data type and can at the first glance give a bit different results that we might think, especially when combined with the .Net framework. Of course hashing itself works correctly in both. &lt;/span&gt;&lt;span class="rem"&gt;Let’s see what going on with some examples. From here on when i say hash i mean MD5 hash.&lt;/span&gt;&lt;/p&gt;
&lt;h4&gt;Example in SQL Server&lt;/h4&gt;
&lt;div&gt;
&lt;pre class="csharpcode"&gt;&lt;span class="rem"&gt;-- note the size 15 of all datatypes&lt;/span&gt;
&lt;span class="kwrd"&gt;declare&lt;/span&gt; @val1 &lt;span class="kwrd"&gt;varchar&lt;/span&gt;(15),
        @val2 nvarchar(15),
        @val3 &lt;span class="kwrd"&gt;char&lt;/span&gt;(15),
        @val4 &lt;span class="kwrd"&gt;nchar&lt;/span&gt;(15)

&lt;span class="rem"&gt;-- example of 1 byte/char text&lt;/span&gt;
&lt;span class="rem"&gt;-- all variables are of same length&lt;/span&gt;
&lt;span class="kwrd"&gt;select&lt;/span&gt;  @val1 =  &lt;span class="str"&gt;'1234567890'&lt;/span&gt;,
        @val2 = N&lt;span class="str"&gt;'1234567890'&lt;/span&gt;,
        @val3 =  &lt;span class="str"&gt;'1234567890'&lt;/span&gt;,
        @val4 = N&lt;span class="str"&gt;'1234567890'&lt;/span&gt;

&lt;span class="rem"&gt;-- all 4 return different results&lt;/span&gt;
&lt;span class="kwrd"&gt;select&lt;/span&gt;  HASHBYTES(&lt;span class="str"&gt;'md5'&lt;/span&gt;, @val1) &lt;span class="kwrd"&gt;as&lt;/span&gt; MD5_varchar,     &lt;span class="rem"&gt;-- result = 0xE807F1FCF82D132F9BB018CA6738A19F&lt;/span&gt;
        &lt;span class="rem"&gt;-- just to show that collation doesn't change the hash&lt;/span&gt;
        HASHBYTES(&lt;span class="str"&gt;'md5'&lt;/span&gt;, @val1 &lt;span class="kwrd"&gt;collate&lt;/span&gt; Cyrillic_General_BIN2) &lt;span class="kwrd"&gt;as&lt;/span&gt; MD5_varchar_collation, &lt;span class="rem"&gt;-- result = 0xE807F1FCF82D132F9BB018CA6738A19F&lt;/span&gt;
        HASHBYTES(&lt;span class="str"&gt;'md5'&lt;/span&gt;, @val2) &lt;span class="kwrd"&gt;as&lt;/span&gt; MD5_Nvarchar,    &lt;span class="rem"&gt;-- result = 0xE15E31C3D8898C92AB172A4311BE9E84&lt;/span&gt;
        HASHBYTES(&lt;span class="str"&gt;'md5'&lt;/span&gt;, @val3) &lt;span class="kwrd"&gt;as&lt;/span&gt; MD5_char,        &lt;span class="rem"&gt;-- result = 0x2120C3F3423F89BA8A65ABD933321884&lt;/span&gt;
        HASHBYTES(&lt;span class="str"&gt;'md5'&lt;/span&gt;, @val4) &lt;span class="kwrd"&gt;as&lt;/span&gt; MD5_Nchar        &lt;span class="rem"&gt;-- result = 0x90DEF5840F3A31174CA44E2022F743B6&lt;/span&gt;

&lt;span class="rem"&gt;-- example of 2 bytes/char text&lt;/span&gt;&lt;/pre&gt;
&lt;pre class="csharpcode"&gt;&lt;span class="rem"&gt;-- 中文 means Chinese in written text&lt;/span&gt;
&lt;span class="rem"&gt;-- converting 2 bytes/char text to varchar cuts the text in half&lt;/span&gt;
&lt;span class="kwrd"&gt;select&lt;/span&gt;  @val1 =  &lt;span class="str"&gt;'中文'&lt;/span&gt;,   &lt;span class="rem"&gt;-- this cuts the text in half&lt;/span&gt;
        @val2 = N&lt;span class="str"&gt;'中文'&lt;/span&gt;,   &lt;span class="rem"&gt;-- this stores the whole text&lt;/span&gt;
        @val3 =  &lt;span class="str"&gt;'中文'&lt;/span&gt;,   &lt;span class="rem"&gt;-- this cuts the text in half&lt;/span&gt;
        @val4 = N&lt;span class="str"&gt;'中文'&lt;/span&gt;    &lt;span class="rem"&gt;-- this stores the whole text&lt;/span&gt;

&lt;span class="rem"&gt;-- all 4 return different results&lt;/span&gt;
&lt;span class="kwrd"&gt;select&lt;/span&gt;  HASHBYTES(&lt;span class="str"&gt;'md5'&lt;/span&gt;, @val1) &lt;span class="kwrd"&gt;as&lt;/span&gt; MD5_varchar,     &lt;span class="rem"&gt;-- result = 0xEA03FCB8C47822BCE772CF6C07D0EBBB&lt;/span&gt;
        HASHBYTES(&lt;span class="str"&gt;'md5'&lt;/span&gt;, @val2) &lt;span class="kwrd"&gt;as&lt;/span&gt; MD5_Nvarchar,    &lt;span class="rem"&gt;-- result = 0x73C6C8CD2F94355EF015E5265D5E65B1&lt;/span&gt;
        HASHBYTES(&lt;span class="str"&gt;'md5'&lt;/span&gt;, @val3) &lt;span class="kwrd"&gt;as&lt;/span&gt; MD5_char,        &lt;span class="rem"&gt;-- result = 0xA13C45A38853677887B4839071537634&lt;/span&gt;
        HASHBYTES(&lt;span class="str"&gt;'md5'&lt;/span&gt;, @val4) &lt;span class="kwrd"&gt;as&lt;/span&gt; MD5_Nchar        &lt;span class="rem"&gt;-- result = 0xEADEBD3BD72A481C43C828E0C550145C&lt;/span&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;div&gt; &lt;/div&gt;
&lt;div&gt;The catch here is the data type difference. Nvarchar and nchar take twice more bytes to store data than varchar and char. Since char and nchar pad the right side of the string with spaces to fill the gap up to defined data type length the spaces are also used in MD5 calculation. A collation plays no part in calculating hash values since collations are only applied to sorts and comparisons.&lt;/div&gt;
&lt;p&gt;However care must be taken with texts that need 2 bytes per char of storage space like Chinese text. Storing it in a varchar variable cuts it in half.&lt;/p&gt;
&lt;h4&gt;Example in .Net - C#&lt;/h4&gt;
&lt;p&gt;For generating MD5 hashes I’ve used the code from &lt;a target="_blank" href="http://blog.brezovsky.net/en-text-2.html"&gt;&lt;strong&gt;&lt;font color="#004080"&gt;this site&lt;/font&gt;&lt;/strong&gt;&lt;/a&gt; which turned up as the first result on Google for “MD5 in C#”:&lt;/p&gt;
&lt;div&gt;
&lt;div&gt;
&lt;pre class="csharpcode"&gt;&lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;string&lt;/span&gt; GetMD5Hash(&lt;span class="kwrd"&gt;string&lt;/span&gt; input)
{
    System.Security.Cryptography.MD5CryptoServiceProvider x = &lt;span class="kwrd"&gt;new&lt;/span&gt; System.Security.Cryptography.MD5CryptoServiceProvider();
    &lt;span class="rem"&gt;//byte[] bs = System.Text.Encoding.ASCII.GetBytes(input);&lt;/span&gt;
    &lt;span class="rem"&gt;//byte[] bs = System.Text.Encoding.UTF7.GetBytes(input);&lt;/span&gt;
    &lt;span class="rem"&gt;//byte[] bs = System.Text.Encoding.UTF8.GetBytes(input);&lt;/span&gt;
    &lt;span class="kwrd"&gt;byte&lt;/span&gt;[] bs = System.Text.Encoding.Unicode.GetBytes(input);
    &lt;span class="rem"&gt;//byte[] bs = System.Text.Encoding.UTF32.GetBytes(input);&lt;/span&gt;
    bs = x.ComputeHash(bs);
    System.Text.StringBuilder s = &lt;span class="kwrd"&gt;new&lt;/span&gt; System.Text.StringBuilder();
    &lt;span class="kwrd"&gt;foreach&lt;/span&gt; (&lt;span class="kwrd"&gt;byte&lt;/span&gt; b &lt;span class="kwrd"&gt;in&lt;/span&gt; bs)
    {
        s.Append(b.ToString(&lt;span class="str"&gt;"x2"&lt;/span&gt;).ToLower());
    }
    &lt;span class="kwrd"&gt;string&lt;/span&gt; password = s.ToString();
    &lt;span class="kwrd"&gt;return&lt;/span&gt; password;
}

&lt;span class="rem"&gt;// hashes for the simple “1234567890” text in all encodings&lt;/span&gt;
ASCII:   e807f1fcf82d132f9bb018ca6738a19f
UTF7:    e807f1fcf82d132f9bb018ca6738a19f
UTF8:    e807f1fcf82d132f9bb018ca6738a19f
Unicode: e15e31c3d8898c92ab172a4311be9e84
UTF32:   6a57502c29a5081f03cb70e0ad38ecc7

&lt;span class="rem"&gt;// hashes for the complex “中文” text in all encodings&lt;/span&gt;
ASCII:   ea03fcb8c47822bce772cf6c07d0ebbb
UTF7:    eb02105e5c51a33f21e8da7f8102cfda
UTF8:    a7bac2239fcdcb3a067903d8077c4a07
Unicode: 73c6c8cd2f94355ef015e5265d5e65b1
UTF32:   65fe91b81ed1107566f9f9f5ed4ccaf1 &lt;/pre&gt;
&lt;/div&gt;
&lt;p&gt; &lt;/p&gt;
&lt;p&gt;All strings in .Net store their chars in 2 bytes by default. When hashing values we have to take this into account and use proper text Encoding. .Net supports 5 encodings: &lt;a target="_blank" href="http://msdn.microsoft.com/en-us/library/system.text.asciiencoding.aspx"&gt;&lt;strong&gt;&lt;font color="#004080"&gt;ASCII&lt;/font&gt;&lt;/strong&gt;&lt;/a&gt; (7 bits per char), &lt;a target="_blank" href="http://msdn.microsoft.com/en-us/library/system.text.utf7encoding.aspx"&gt;&lt;strong&gt;&lt;font color="#004080"&gt;UTF7&lt;/font&gt;&lt;/strong&gt;&lt;/a&gt; (7 bits per char), &lt;a target="_blank" href="http://msdn.microsoft.com/en-us/library/system.text.utf8encoding.aspx"&gt;&lt;strong&gt;&lt;font color="#004080"&gt;UTF8&lt;/font&gt;&lt;/strong&gt;&lt;/a&gt; (8 bits = 1 byte per char), &lt;a target="_blank" href="http://msdn.microsoft.com/en-us/library/system.text.unicodeencoding.aspx"&gt;&lt;strong&gt;&lt;font color="#004080"&gt;Unicode (UTF-16)&lt;/font&gt;&lt;/strong&gt;&lt;/a&gt; (16 bits = 2 bytes per char) and &lt;a target="_blank" href="http://msdn.microsoft.com/en-us/library/system.text.utf32encoding.aspx"&gt;&lt;strong&gt;&lt;font color="#004080"&gt;UTF32&lt;/font&gt;&lt;/strong&gt;&lt;/a&gt; (32 bits = 4 bytes per char). &lt;/p&gt;
&lt;p&gt;For text with only first 127 chars in the ASCII table ASCII, UTF7 and UTF8 encodings all return the same hash, but with UTF16 and UTF32 comes &lt;a target="_blank" href="http://en.wikipedia.org/wiki/Endianness"&gt;&lt;strong&gt;&lt;font color="#004080"&gt;endianness&lt;/font&gt;&lt;/strong&gt;&lt;/a&gt; so they don’t return the same hash values. Also note that the ASCII and UTF7 encoding aren’t recommended to be used anymore except in legacy apps. UTF8 should be used instead.&lt;/p&gt;
&lt;p&gt;For text with complex chars we have to use Unicode or UTF32 or we loose char information.&lt;/p&gt;
&lt;/div&gt;
&lt;h4&gt;Putting .Net and SQL Server together&lt;/h4&gt;
&lt;p&gt; &lt;/p&gt;
&lt;p&gt;It turns out that such a simple thing as hashing can become a serious issue if we’re not careful. Trouble always awaits when dealing with text and encodings. :)&lt;/p&gt;
&lt;p&gt;When using SQL Server’s varchar data type the .Net encoding to go with is UTF8 since it’s the fastest and most optimized of the three (ASCII, UTF7, UTF8). When using the nvarchar data type to go is Unicode (UTF16) but we also have to know the texts endianness to create correct hashes. UTF32 is practically useless in this case because SQL Server doesn’t have a data type that stores text in 4 bytes/char so we’ll never get the same results if we use it.&lt;/p&gt;
&lt;p&gt;This advice only applies when creating hashes both in .Net and SQL server and comparing them. If we’re creating hashes in .Net and only store them in a database then we don’t have to worry about this.&lt;/p&gt;
&lt;p&gt; &lt;/p&gt;
&lt;a href="http://www.dotnetkicks.com/kick/?url=http%3a%2f%2fweblogs.sqlteam.com%2fmladenp%2farchive%2f2009%2f04%2f28%2fComparing-SQL-Server-HASHBYTES-function-and-.Net-hashing.aspx"&gt;&lt;img border="0" alt="kick it on DotNetKicks.com" src="http://www.dotnetkicks.com/Services/Images/KickItImageGenerator.ashx?url=http%3a%2f%2fweblogs.sqlteam.com%2fmladenp%2farchive%2f2009%2f04%2f28%2fComparing-SQL-Server-HASHBYTES-function-and-.Net-hashing.aspx" /&gt;&lt;/a&gt;&lt;img src="http://weblogs.sqlteam.com/mladenp/aggbug/60902.aspx" width="1" height="1" /&gt;
&lt;p&gt;&lt;a href="http://feedads.g.doubleclick.net/~a/cBChyG4ZU_LAmQpZD3AJvbBgq2Q/0/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/cBChyG4ZU_LAmQpZD3AJvbBgq2Q/0/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;br/&gt;
&lt;a href="http://feedads.g.doubleclick.net/~a/cBChyG4ZU_LAmQpZD3AJvbBgq2Q/1/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/cBChyG4ZU_LAmQpZD3AJvbBgq2Q/1/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;/p&gt;</description>
            <dc:creator>Mladen Prajdić</dc:creator>
            <guid isPermaLink="false">http://weblogs.sqlteam.com/mladenp/archive/2009/04/28/Comparing-SQL-Server-HASHBYTES-function-and-.Net-hashing.aspx</guid>
            <pubDate>Tue, 28 Apr 2009 09:43:21 GMT</pubDate>
            <wfw:comment>http://weblogs.sqlteam.com/mladenp/comments/60902.aspx</wfw:comment>
            <comments>http://weblogs.sqlteam.com/mladenp/archive/2009/04/28/Comparing-SQL-Server-HASHBYTES-function-and-.Net-hashing.aspx#feedback</comments>
            <slash:comments>2</slash:comments>
            <wfw:commentRss>http://weblogs.sqlteam.com/mladenp/comments/commentRss/60902.aspx</wfw:commentRss>
            <trackback:ping>http://weblogs.sqlteam.com/mladenp/services/trackbacks/60902.aspx</trackback:ping>
        <feedburner:origLink>http://weblogs.sqlteam.com/mladenp/archive/2009/04/28/Comparing-SQL-Server-HASHBYTES-function-and-.Net-hashing.aspx</feedburner:origLink></item>
        <item>
            <title>SQL Server - Find missing and unused indexes</title>
            <link>http://feedproxy.google.com/~r/mladenp/~3/HQuj4tPxl38/SQL-Server---Find-missing-and-unused-indexes.aspx</link>
            <description>&lt;p&gt;Indexes are one of the most important database features. Without them your database will crawl under a table in fear of simple queries on large tables or complex queries on small tables. That’s why one of the most important things a DBA or a database developer should know is basic index maintenance. &lt;/p&gt;
&lt;p&gt;Performance problems are usually result of missing indexes. Index tuning is more of an art than it is a science since possible workloads are so many that there is no one rule to rule them all. It’s a mixture of testing, implementing, retesting and reimplementing. For this purpose The SQL Server team has created the &lt;a target="_blank" href="http://msdn.microsoft.com/en-us/library/ms173494.aspx"&gt;&lt;strong&gt;&lt;font color="#004080"&gt;Database Tuning Advisor&lt;/font&gt;&lt;/strong&gt;&lt;/a&gt; that takes a recorded workload (from SQL Profiler), analyzes it and suggests index improvements. However this is a tool for some really deep analysis, so we’ll take a look at some lightweight options.&lt;/p&gt;
&lt;p&gt;On the other hand too many unused indexes bloat the database and unnecessarily increase the database size. This can cause problems with larger backups that take longer to create. This is why there’s a delicate balance to keep when maintaining indexes.&lt;/p&gt;
&lt;p&gt;With SQL Server 2005 we got introduced to &lt;a target="_blank" href="http://msdn.microsoft.com/en-us/library/ms188754.aspx"&gt;&lt;strong&gt;&lt;font color="#004080"&gt;Dynamic Management Views&lt;/font&gt;&lt;/strong&gt;&lt;/a&gt; (DMV’s). They are a powerful tool when troubleshooting SQL Server performance. Their downside is that most of them hold aggregated values since server start. That’s why we have to poll them twice at the start and at the end of the desired interval to get meaningful results. However for our purpose we don’t have to do this since we want to know which indexes are not used since our server started. We can find this information because when building an execution plan the SQL Server keeps information about every index it has used and could have used because it’s a &lt;a target="_blank" href="http://weblogs.sqlteam.com/mladenp/archive/2008/02/25/How-SQL-Server-short-circuits-WHERE-condition-evaluation.aspx"&gt;&lt;strong&gt;&lt;font color="#004080"&gt;cost based engine&lt;/font&gt;&lt;/strong&gt;&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt; &lt;/p&gt;
&lt;h4&gt;Finding missing indexes&lt;/h4&gt;
&lt;p&gt;&lt;strong&gt;Needed Dynamic Management Views (DMV’s) &lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;As I said earlier SQL Server keeps data about possible missing indexes. If an actual execution plan is included when running a query then the &lt;a target="_blank" href="http://weblogs.sqlteam.com/mladenp/archive/2008/12/29/SQL-Server-Management-Studio-2008-suggests-missing-indexes-with-actual.aspx"&gt;&lt;strong&gt;&lt;font color="#004080"&gt;missing indexes are also displayed there&lt;/font&gt;&lt;/strong&gt;&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;The data about missing indexes is stored in the following DMV’s which all exclude info about spatial indexes:&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;&lt;em&gt;sys.dm_db_missing_index_groups&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;This DMV returns only 2 columns with information about which indexes are in which group. &lt;/p&gt;
&lt;p&gt;&lt;em&gt;&lt;strong&gt;sys.dm_db_missing_index_group_stats&lt;/strong&gt;&lt;/em&gt;&lt;/p&gt;
&lt;p&gt;This DMV returns information about each missing indexes group. It returns info like the estimated average impact or how many seeks, scans and compilations/recompilations would benefit from adding the missing indexes. &lt;/p&gt;
&lt;p&gt;&lt;strong&gt;&lt;em&gt;sys.dm_db_missing_index_details&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;This DMV returns detailed information about each missing index like table name that is missing an index and CSV’s of columns that the index would be beneficial on. &lt;/p&gt;
&lt;p&gt;&lt;strong&gt;&lt;em&gt;sys.dm_db_missing_index_columns&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;
&lt;p align="left"&gt;This a Dynamic Management Function (DMF) that accepts an index_handle parameter. It returns columns that should be in the suggested index identified with the index_handle that can be obtained from sys.dm_db_missing_index_details and sys.dm_db_missing_index_groups. It does not include spatial indexes. The column named column_usage returns info on how this column would benefit for a particular index. EQUALITY and INEQUALITY mean that the column would be used in a where clause predicate. INCLUDE means that the column should be an included column on an existing non-clustered index. &lt;/p&gt;
&lt;p align="left"&gt; &lt;/p&gt;
&lt;p&gt;&lt;strong&gt;&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;A simple example&lt;/strong&gt;&lt;/p&gt;
&lt;div&gt;
&lt;pre class="csharpcode"&gt;&lt;span class="kwrd"&gt;USE&lt;/span&gt; AdventureWorks;
&lt;span class="kwrd"&gt;GO&lt;/span&gt;
&lt;span class="rem"&gt;-- run some queries&lt;/span&gt;
&lt;span class="kwrd"&gt;SELECT&lt;/span&gt;  City, ModifiedDate
&lt;span class="kwrd"&gt;FROM&lt;/span&gt;    Person.Address
&lt;span class="kwrd"&gt;WHERE&lt;/span&gt;   StateProvinceID &amp;lt; 1000 &lt;span class="kwrd"&gt;AND&lt;/span&gt; ModifiedDate &amp;gt; DATEADD(yyyy, -5, GETDATE());
&lt;span class="kwrd"&gt;GO&lt;/span&gt;
&lt;span class="kwrd"&gt;SELECT&lt;/span&gt;  City, StateProvinceID, PostalCode
&lt;span class="kwrd"&gt;FROM&lt;/span&gt;    Person.Address
&lt;span class="kwrd"&gt;WHERE&lt;/span&gt;   StateProvinceID = 15733;
&lt;span class="kwrd"&gt;GO&lt;/span&gt;
&lt;span class="rem"&gt;-- get the missing indexes that would be beneficial for speeding up above queries&lt;/span&gt;
&lt;span class="kwrd"&gt;SELECT&lt;/span&gt;  D.index_handle, [&lt;span class="kwrd"&gt;statement&lt;/span&gt;] &lt;span class="kwrd"&gt;AS&lt;/span&gt; full_object_name, unique_compiles, avg_user_impact, user_scans, user_seeks, column_name, column_usage
&lt;span class="kwrd"&gt;FROM&lt;/span&gt;    sys.dm_db_missing_index_groups G
        &lt;span class="kwrd"&gt;JOIN&lt;/span&gt; sys.dm_db_missing_index_group_stats GS &lt;span class="kwrd"&gt;ON&lt;/span&gt; G.index_group_handle = GS.group_handle
        &lt;span class="kwrd"&gt;JOIN&lt;/span&gt; sys.dm_db_missing_index_details D &lt;span class="kwrd"&gt;ON&lt;/span&gt; G.index_handle = D.index_handle
        &lt;span class="kwrd"&gt;CROSS&lt;/span&gt; APPLY sys.dm_db_missing_index_columns (D.index_handle) DC
&lt;span class="kwrd"&gt;ORDER&lt;/span&gt; &lt;span class="kwrd"&gt;BY&lt;/span&gt; D.index_handle, [&lt;span class="kwrd"&gt;statement&lt;/span&gt;];&lt;/pre&gt;
&lt;/div&gt;
&lt;p&gt; &lt;/p&gt;
&lt;p&gt;The DMV’s return raw data so you’ll have to do some string magic to build the CREATE INDEX statements out of it. &lt;/p&gt;
&lt;p&gt; &lt;/p&gt;
&lt;p&gt;&lt;strong&gt;&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Limitations&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;This cool feature of course has some limitations. Some of those are:&lt;/p&gt;
&lt;ul&gt;
    &lt;li&gt;
    &lt;p&gt;Database Engine Tuning Advisor kicks its behind. Think of Missing Indexes DMV’s as a really lightweight DTA. So when doing a really in-depth index analysis, don’t rely only on the Missing Indexes DMV’s. Just start with them.&lt;/p&gt;
    &lt;/li&gt;
    &lt;li&gt;
    &lt;p&gt;Missing Indexes DMV’s don’t provide any information about new index overhead like space or IO/CPU overhead on updates, inserts and deletes.&lt;/p&gt;
    &lt;/li&gt;
    &lt;li&gt;
    &lt;p&gt;There’s no information about the column order in the suggested index or whether it should be clustered or non-clustered.&lt;/p&gt;
    &lt;/li&gt;
    &lt;li&gt;
    &lt;p&gt;Missing Indexes DMV’s consider only per query indexes and not per workload indexes.&lt;/p&gt;
    &lt;/li&gt;
    &lt;li&gt;
    &lt;p&gt;Missing Indexes DMV’s can track a maximum of 500 indexes.&lt;/p&gt;
    &lt;/li&gt;
    &lt;li&gt;
    &lt;p&gt;Trivial execution plans (plans for really simple SQL Statements) are not considered.&lt;/p&gt;
    &lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt; &lt;/p&gt;
&lt;p&gt; &lt;/p&gt;
&lt;h4&gt;Finding unused indexes&lt;/h4&gt;
&lt;p&gt;Since SQL Server keeps data of all used indexes, getting the unused indexes is a simple matter of comparing used indexes to all existing indexes. Those that exist but are not used are of course unused indexes.&lt;/p&gt;
&lt;div&gt;
&lt;pre class="csharpcode"&gt;&lt;span class="kwrd"&gt;SELECT&lt;/span&gt;  OBJECT_SCHEMA_NAME(I.OBJECT_ID) &lt;span class="kwrd"&gt;AS&lt;/span&gt; SchemaName,
        OBJECT_NAME(I.OBJECT_ID) &lt;span class="kwrd"&gt;AS&lt;/span&gt; ObjectName,
        I.NAME &lt;span class="kwrd"&gt;AS&lt;/span&gt; IndexName        
&lt;span class="kwrd"&gt;FROM&lt;/span&gt;    sys.indexes I   
&lt;span class="kwrd"&gt;WHERE&lt;/span&gt;   &lt;span class="rem"&gt;-- only get indexes for user created tables&lt;/span&gt;
        OBJECTPROPERTY(I.OBJECT_ID, &lt;span class="str"&gt;'IsUserTable'&lt;/span&gt;) = 1 
        &lt;span class="rem"&gt;-- find all indexes that exists but are NOT used&lt;/span&gt;
        &lt;span class="kwrd"&gt;AND&lt;/span&gt; &lt;span class="kwrd"&gt;NOT&lt;/span&gt; &lt;span class="kwrd"&gt;EXISTS&lt;/span&gt; ( 
                    &lt;span class="kwrd"&gt;SELECT&lt;/span&gt;  index_id 
                    &lt;span class="kwrd"&gt;FROM&lt;/span&gt;    sys.dm_db_index_usage_stats
                    &lt;span class="kwrd"&gt;WHERE&lt;/span&gt;   OBJECT_ID = I.OBJECT_ID 
                            &lt;span class="kwrd"&gt;AND&lt;/span&gt; I.index_id = index_id 
                            &lt;span class="rem"&gt;-- limit our query only for the current db&lt;/span&gt;
                            &lt;span class="kwrd"&gt;AND&lt;/span&gt; database_id = DB_ID()) 
&lt;span class="kwrd"&gt;ORDER&lt;/span&gt; &lt;span class="kwrd"&gt;BY&lt;/span&gt; SchemaName, ObjectName, IndexName &lt;/pre&gt;
&lt;/div&gt;
&lt;p&gt; &lt;/p&gt;
&lt;p&gt;Note that both these methods are only useful if your server has been running long enough and has been through peek usage. The data in the mentioned DMV’s is cleared on the next instance restart. If we want to save this information for further analysis we should create a scheduled job that periodically queries the DMV’s and saves the information to tables.&lt;/p&gt;
&lt;p&gt; &lt;/p&gt;
&lt;a href="http://www.dotnetkicks.com/kick/?url=http%3a%2f%2fweblogs.sqlteam.com%2fmladenp%2farchive%2f2009%2f04%2f08%2fSQL-Server---Find-missing-and-unused-indexes.aspx"&gt;&lt;img border="0" alt="kick it on DotNetKicks.com" src="http://www.dotnetkicks.com/Services/Images/KickItImageGenerator.ashx?url=http%3a%2f%2fweblogs.sqlteam.com%2fmladenp%2farchive%2f2009%2f04%2f08%2fSQL-Server---Find-missing-and-unused-indexes.aspx" /&gt;&lt;/a&gt;&lt;img src="http://weblogs.sqlteam.com/mladenp/aggbug/60892.aspx" width="1" height="1" /&gt;
&lt;p&gt;&lt;a href="http://feedads.g.doubleclick.net/~a/AyVcN2_muDvdFc6j5KOMRUePEls/0/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/AyVcN2_muDvdFc6j5KOMRUePEls/0/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;br/&gt;
&lt;a href="http://feedads.g.doubleclick.net/~a/AyVcN2_muDvdFc6j5KOMRUePEls/1/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/AyVcN2_muDvdFc6j5KOMRUePEls/1/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;/p&gt;</description>
            <dc:creator>Mladen Prajdić</dc:creator>
            <guid isPermaLink="false">http://weblogs.sqlteam.com/mladenp/archive/2009/04/08/SQL-Server---Find-missing-and-unused-indexes.aspx</guid>
            <pubDate>Wed, 08 Apr 2009 21:46:21 GMT</pubDate>
            <wfw:comment>http://weblogs.sqlteam.com/mladenp/comments/60892.aspx</wfw:comment>
            <comments>http://weblogs.sqlteam.com/mladenp/archive/2009/04/08/SQL-Server---Find-missing-and-unused-indexes.aspx#feedback</comments>
            <slash:comments>4</slash:comments>
            <wfw:commentRss>http://weblogs.sqlteam.com/mladenp/comments/commentRss/60892.aspx</wfw:commentRss>
            <trackback:ping>http://weblogs.sqlteam.com/mladenp/services/trackbacks/60892.aspx</trackback:ping>
        <feedburner:origLink>http://weblogs.sqlteam.com/mladenp/archive/2009/04/08/SQL-Server---Find-missing-and-unused-indexes.aspx</feedburner:origLink></item>
        <item>
            <title>What was my first computer and what were some of my favorite games?</title>
            <link>http://feedproxy.google.com/~r/mladenp/~3/idqhulgiQ54/What-was-my-first-computer-and-what-were-some-of.aspx</link>
            <description>&lt;p&gt;I was tagged by &lt;a target="_blank" href="http://sqlblog.com/blogs/denis_gobo/"&gt;&lt;strong&gt;&lt;font color="#004080"&gt;Denis Gobo&lt;/font&gt;&lt;/strong&gt;&lt;/a&gt; in the latest blog meme: What was your first computer and games you’ve played?&lt;/p&gt;
&lt;p&gt; &lt;/p&gt;
&lt;p&gt;&lt;img style="DISPLAY: inline; MARGIN-LEFT: 0px; MARGIN-RIGHT: 0px" height="222" alt="" width="303" align="left" src="http://upload.wikimedia.org/wikipedia/commons/3/33/ZXSpectrum48k.jpg" /&gt;Well  mine was the &lt;a href="http://en.wikipedia.org/wiki/ZX_Spectrum"&gt;&lt;strong&gt;&lt;font color="#004080"&gt;Sinclair ZX Spectrum&lt;/font&gt;&lt;/strong&gt;&lt;/a&gt;. &lt;/p&gt;
&lt;p&gt;I got it when i was 9 years old and I only used it to play games. No programming for this kid just yet. That came a lot later. &lt;/p&gt;
&lt;p&gt;This baby had a tape drive whose sound I really enjoyed imitating to annoy my mom :)&lt;/p&gt;
&lt;p&gt; &lt;/p&gt;
&lt;p&gt; &lt;/p&gt;
&lt;p&gt; &lt;/p&gt;
&lt;p&gt; &lt;/p&gt;
&lt;p&gt; &lt;/p&gt;
&lt;p&gt;So what were some of the games? These are the four I remember:&lt;/p&gt;
&lt;p&gt;&lt;a href="http://en.wikipedia.org/wiki/Grand_Prix_Circuit"&gt;&lt;strong&gt;&lt;font color="#004080"&gt;Grand Prix Circuit&lt;/font&gt;&lt;/strong&gt;&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;This was my first intro into the world of F1. I can still remember the “eeeeee cccccc  beep beep beep” sounds of the engine and tires. Ahhhh, those were the days…&lt;/p&gt;
&lt;p&gt;&lt;img style="BORDER-TOP-WIDTH: 0px; BORDER-LEFT-WIDTH: 0px; BORDER-BOTTOM-WIDTH: 0px; BORDER-RIGHT-WIDTH: 0px" height="200" alt="" width="320" border="0" src="http://upload.wikimedia.org/wikipedia/en/7/72/Grand_Prix_Circuit_PC.png" /&gt;  &lt;/p&gt;
&lt;p&gt; &lt;/p&gt;
&lt;p&gt;&lt;a target="_blank" href="http://en.wikipedia.org/wiki/Chessmaster"&gt;&lt;strong&gt;&lt;font color="#004080"&gt;The Chessmaster 2000&lt;/font&gt;&lt;/strong&gt;&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;My first chess program. I was taught chess at the age of 4 by my uncle and have played it more or less actively since. I remember staying up late for many of nights trying to beat it.&lt;/p&gt;
&lt;p&gt; &lt;a href="http://weblogs.sqlteam.com/images/weblogs_sqlteam_com/mladenp/WindowsLiveWriter/Myfirstcomputer_119D6/Chessmaster_2000_2.png"&gt;&lt;img title="Chessmaster_2000" style="BORDER-TOP-WIDTH: 0px; DISPLAY: inline; BORDER-LEFT-WIDTH: 0px; BORDER-BOTTOM-WIDTH: 0px; BORDER-RIGHT-WIDTH: 0px" height="314" alt="Chessmaster_2000" width="294" border="0" src="http://weblogs.sqlteam.com/images/weblogs_sqlteam_com/mladenp/WindowsLiveWriter/Myfirstcomputer_119D6/Chessmaster_2000_thumb.png" /&gt;&lt;/a&gt; &lt;/p&gt;
&lt;p&gt; &lt;/p&gt;
&lt;p&gt;&lt;a href="http://en.wikipedia.org/wiki/Frogger"&gt;&lt;strong&gt;&lt;font color="#004080"&gt;Frogger&lt;/font&gt;&lt;/strong&gt;&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;The one, the only, the ultimate - the frog! Up, down, all around, left, right, jump with might! Such simplicity yet so playable. Even today I like to play a game of Frogger now and then.&lt;/p&gt;
&lt;p&gt;&lt;img height="342" alt="" width="300" src="http://upload.wikimedia.org/wikipedia/en/c/cd/Frogger_game_arcade.png" /&gt; &lt;/p&gt;
&lt;p&gt; &lt;/p&gt;
&lt;p&gt; &lt;/p&gt;
&lt;p&gt; &lt;/p&gt;
&lt;p&gt;&lt;a href="http://en.wikipedia.org/wiki/Popeye_(arcade_game)"&gt;&lt;strong&gt;&lt;font color="#004080"&gt;Popeye&lt;/font&gt;&lt;/strong&gt;&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;This one I enjoyed playing but i haven no clue why. Probably to bring out my romantic side as the game was filled with hearts and winning the lady. :)&lt;/p&gt;
&lt;p&gt;&lt;img height="265" alt="" width="302" src="http://upload.wikimedia.org/wikipedia/en/4/4e/Popeye.png" /&gt; &lt;/p&gt;
&lt;p&gt;That’s it.&lt;/p&gt;
&lt;p&gt; &lt;/p&gt;
&lt;p&gt;I’m tagging &lt;a target="_blank" href="http://weblogs.sqlteam.com/jeffs"&gt;&lt;strong&gt;&lt;font color="#004080"&gt;Jeff Smith&lt;/font&gt;&lt;/strong&gt;&lt;/a&gt;, &lt;a target="_blank" href="http://weblogs.sqlteam.com/peterl/"&gt;&lt;strong&gt;&lt;font color="#004080"&gt;Peter Larsson&lt;/font&gt;&lt;/strong&gt;&lt;/a&gt;, &lt;a target="_blank" href="http://sqlblog.com/blogs/adam_machanic"&gt;&lt;strong&gt;&lt;font color="#004080"&gt;Adam Machanic&lt;/font&gt;&lt;/strong&gt;&lt;/a&gt; and &lt;a target="_blank" href="http://arcanecode.wordpress.com/"&gt;&lt;strong&gt;&lt;font color="#004080"&gt;Robert C. Cain&lt;/font&gt;&lt;/strong&gt;&lt;/a&gt; to tell us what they had and played with.&lt;/p&gt;&lt;img src="http://weblogs.sqlteam.com/mladenp/aggbug/60846.aspx" width="1" height="1" /&gt;
&lt;p&gt;&lt;a href="http://feedads.g.doubleclick.net/~a/McIne6L7ZYJvzyYJqyAmInJgZjQ/0/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/McIne6L7ZYJvzyYJqyAmInJgZjQ/0/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;br/&gt;
&lt;a href="http://feedads.g.doubleclick.net/~a/McIne6L7ZYJvzyYJqyAmInJgZjQ/1/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/McIne6L7ZYJvzyYJqyAmInJgZjQ/1/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;/p&gt;</description>
            <dc:creator>Mladen Prajdić</dc:creator>
            <guid isPermaLink="false">http://weblogs.sqlteam.com/mladenp/archive/2009/02/19/What-was-my-first-computer-and-what-were-some-of.aspx</guid>
            <pubDate>Thu, 19 Feb 2009 19:44:35 GMT</pubDate>
            <wfw:comment>http://weblogs.sqlteam.com/mladenp/comments/60846.aspx</wfw:comment>
            <comments>http://weblogs.sqlteam.com/mladenp/archive/2009/02/19/What-was-my-first-computer-and-what-were-some-of.aspx#feedback</comments>
            <slash:comments>5</slash:comments>
            <wfw:commentRss>http://weblogs.sqlteam.com/mladenp/comments/commentRss/60846.aspx</wfw:commentRss>
            <trackback:ping>http://weblogs.sqlteam.com/mladenp/services/trackbacks/60846.aspx</trackback:ping>
        <feedburner:origLink>http://weblogs.sqlteam.com/mladenp/archive/2009/02/19/What-was-my-first-computer-and-what-were-some-of.aspx</feedburner:origLink></item>
    </channel>
</rss>
