<rss version="2.0" 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/">
    <channel>
        <title>Chris Crowe</title>
        <link>http://blog.crowe.co.nz/blog/Default.aspx</link>
        <description />
        <language>en-NZ</language>
        <copyright>Chris Crowe</copyright>
        <generator>Subtext Version 2.5.0.3</generator>
        <image>
            <title>Chris Crowe</title>
            <url>http://blog.crowe.co.nz/blog/images/RSS2Image.gif</url>
            <link>http://blog.crowe.co.nz/blog/Default.aspx</link>
            <width>77</width>
            <height>60</height>
        </image>
        <item>
            <title>asp.net - output cache &amp;ndash; optional caching</title>
            <category>c#</category>
            <category>asp.net</category>
            <category>caching</category>
            <link>http://blog.crowe.co.nz/blog/archive/2013/04/17/test-post.aspx</link>
            <description>&lt;p&gt;This post is about using the asp.net output cache but also having a small bit of flexibility to allow some requests not to be cached – sort of.&lt;/p&gt;  &lt;p&gt;In my case I wanted my dynamically generated charts to be cached in asp.net for a period of time such as 60 minutes, but I did not want the chart for today to be cached at all since the chart is always updating.&lt;/p&gt;  &lt;p&gt;&lt;a href="http://blog.crowe.co.nz/blog/images/blog_crowe_co_nz/blog/Windows-Live-Writer/Test-Post_951D/image_2.png"&gt;&lt;img title="image" style="border-left-width: 0px; border-right-width: 0px; background-image: none; border-bottom-width: 0px; padding-top: 0px; padding-left: 0px; display: inline; padding-right: 0px; border-top-width: 0px" border="0" alt="image" src="http://blog.crowe.co.nz/blog/images/blog_crowe_co_nz/blog/Windows-Live-Writer/Test-Post_951D/image_thumb.png" width="755" height="35" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;By using the &lt;strong&gt;VaryByCustom&lt;/strong&gt; tag you can then create a sort of conditional caching method.&lt;/p&gt;  &lt;p&gt;We will override the &lt;strong&gt;GetVaryByCustomString&lt;/strong&gt;() method in the &lt;strong&gt;global.asax&lt;/strong&gt; file&lt;/p&gt;    &lt;div id="codeSnippetWrapper"&gt;   &lt;div id="codeSnippet" style="border-top-style: none; overflow: visible; font-size: 8pt; border-left-style: none; font-family: 'Courier New', courier, monospace; border-bottom-style: none; color: black; padding-bottom: 0px; direction: ltr; text-align: left; padding-top: 0px; border-right-style: none; padding-left: 0px; line-height: 12pt; padding-right: 0px; width: 100%; background-color: #f4f4f4"&gt;     &lt;pre style="border-top-style: none; overflow: visible; font-size: 8pt; border-left-style: none; font-family: 'Courier New', courier, monospace; border-bottom-style: none; color: black; padding-bottom: 0px; direction: ltr; text-align: left; padding-top: 0px; border-right-style: none; padding-left: 0px; margin: 0em; line-height: 12pt; padding-right: 0px; width: 100%; background-color: white"&gt;&lt;span id="lnum1" style="color: #606060"&gt;   1:&lt;/span&gt; &lt;span style="color: #0000ff"&gt;public&lt;/span&gt; &lt;span style="color: #0000ff"&gt;override&lt;/span&gt; &lt;span style="color: #0000ff"&gt;string&lt;/span&gt; GetVaryByCustomString(HttpContext context, &lt;span style="color: #0000ff"&gt;string&lt;/span&gt; custom)&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-top-style: none; overflow: visible; font-size: 8pt; border-left-style: none; font-family: 'Courier New', courier, monospace; border-bottom-style: none; color: black; padding-bottom: 0px; direction: ltr; text-align: left; padding-top: 0px; border-right-style: none; padding-left: 0px; margin: 0em; line-height: 12pt; padding-right: 0px; width: 100%; background-color: #f4f4f4"&gt;&lt;span id="lnum2" style="color: #606060"&gt;   2:&lt;/span&gt;    {        &lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-top-style: none; overflow: visible; font-size: 8pt; border-left-style: none; font-family: 'Courier New', courier, monospace; border-bottom-style: none; color: black; padding-bottom: 0px; direction: ltr; text-align: left; padding-top: 0px; border-right-style: none; padding-left: 0px; margin: 0em; line-height: 12pt; padding-right: 0px; width: 100%; background-color: white"&gt;&lt;span id="lnum3" style="color: #606060"&gt;   3:&lt;/span&gt;        &lt;span style="color: #0000ff"&gt;if&lt;/span&gt; (&lt;span style="color: #0000ff"&gt;string&lt;/span&gt;.Compare(custom, &lt;span style="color: #006080"&gt;"data"&lt;/span&gt;, &lt;span style="color: #0000ff"&gt;true&lt;/span&gt;) == 0)&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-top-style: none; overflow: visible; font-size: 8pt; border-left-style: none; font-family: 'Courier New', courier, monospace; border-bottom-style: none; color: black; padding-bottom: 0px; direction: ltr; text-align: left; padding-top: 0px; border-right-style: none; padding-left: 0px; margin: 0em; line-height: 12pt; padding-right: 0px; width: 100%; background-color: #f4f4f4"&gt;&lt;span id="lnum4" style="color: #606060"&gt;   4:&lt;/span&gt;        {&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-top-style: none; overflow: visible; font-size: 8pt; border-left-style: none; font-family: 'Courier New', courier, monospace; border-bottom-style: none; color: black; padding-bottom: 0px; direction: ltr; text-align: left; padding-top: 0px; border-right-style: none; padding-left: 0px; margin: 0em; line-height: 12pt; padding-right: 0px; width: 100%; background-color: white"&gt;&lt;span id="lnum5" style="color: #606060"&gt;   5:&lt;/span&gt;            &lt;span style="color: #0000ff"&gt;if&lt;/span&gt; (Request.QueryString[&lt;span style="color: #006080"&gt;"NoCache"&lt;/span&gt;] != &lt;span style="color: #0000ff"&gt;null&lt;/span&gt;)&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-top-style: none; overflow: visible; font-size: 8pt; border-left-style: none; font-family: 'Courier New', courier, monospace; border-bottom-style: none; color: black; padding-bottom: 0px; direction: ltr; text-align: left; padding-top: 0px; border-right-style: none; padding-left: 0px; margin: 0em; line-height: 12pt; padding-right: 0px; width: 100%; background-color: #f4f4f4"&gt;&lt;span id="lnum6" style="color: #606060"&gt;   6:&lt;/span&gt;                &lt;span style="color: #0000ff"&gt;return&lt;/span&gt; Guid.NewGuid().ToString();&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-top-style: none; overflow: visible; font-size: 8pt; border-left-style: none; font-family: 'Courier New', courier, monospace; border-bottom-style: none; color: black; padding-bottom: 0px; direction: ltr; text-align: left; padding-top: 0px; border-right-style: none; padding-left: 0px; margin: 0em; line-height: 12pt; padding-right: 0px; width: 100%; background-color: white"&gt;&lt;span id="lnum7" style="color: #606060"&gt;   7:&lt;/span&gt;            &lt;span style="color: #0000ff"&gt;else&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-top-style: none; overflow: visible; font-size: 8pt; border-left-style: none; font-family: 'Courier New', courier, monospace; border-bottom-style: none; color: black; padding-bottom: 0px; direction: ltr; text-align: left; padding-top: 0px; border-right-style: none; padding-left: 0px; margin: 0em; line-height: 12pt; padding-right: 0px; width: 100%; background-color: #f4f4f4"&gt;&lt;span id="lnum8" style="color: #606060"&gt;   8:&lt;/span&gt;                &lt;span style="color: #0000ff"&gt;return&lt;/span&gt; Request.QueryString[&lt;span style="color: #006080"&gt;"Data"&lt;/span&gt;];&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-top-style: none; overflow: visible; font-size: 8pt; border-left-style: none; font-family: 'Courier New', courier, monospace; border-bottom-style: none; color: black; padding-bottom: 0px; direction: ltr; text-align: left; padding-top: 0px; border-right-style: none; padding-left: 0px; margin: 0em; line-height: 12pt; padding-right: 0px; width: 100%; background-color: white"&gt;&lt;span id="lnum9" style="color: #606060"&gt;   9:&lt;/span&gt;        }&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-top-style: none; overflow: visible; font-size: 8pt; border-left-style: none; font-family: 'Courier New', courier, monospace; border-bottom-style: none; color: black; padding-bottom: 0px; direction: ltr; text-align: left; padding-top: 0px; border-right-style: none; padding-left: 0px; margin: 0em; line-height: 12pt; padding-right: 0px; width: 100%; background-color: #f4f4f4"&gt;&lt;span id="lnum10" style="color: #606060"&gt;  10:&lt;/span&gt;        &lt;span style="color: #0000ff"&gt;else&lt;/span&gt;            &lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-top-style: none; overflow: visible; font-size: 8pt; border-left-style: none; font-family: 'Courier New', courier, monospace; border-bottom-style: none; color: black; padding-bottom: 0px; direction: ltr; text-align: left; padding-top: 0px; border-right-style: none; padding-left: 0px; margin: 0em; line-height: 12pt; padding-right: 0px; width: 100%; background-color: white"&gt;&lt;span id="lnum11" style="color: #606060"&gt;  11:&lt;/span&gt;            &lt;span style="color: #0000ff"&gt;return&lt;/span&gt; &lt;span style="color: #0000ff"&gt;base&lt;/span&gt;.GetVaryByCustomString(context, custom);&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-top-style: none; overflow: visible; font-size: 8pt; border-left-style: none; font-family: 'Courier New', courier, monospace; border-bottom-style: none; color: black; padding-bottom: 0px; direction: ltr; text-align: left; padding-top: 0px; border-right-style: none; padding-left: 0px; margin: 0em; line-height: 12pt; padding-right: 0px; width: 100%; background-color: #f4f4f4"&gt;&lt;span id="lnum12" style="color: #606060"&gt;  12:&lt;/span&gt;    }&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-top-style: none; overflow: visible; font-size: 8pt; border-left-style: none; font-family: 'Courier New', courier, monospace; border-bottom-style: none; color: black; padding-bottom: 0px; direction: ltr; text-align: left; padding-top: 0px; border-right-style: none; padding-left: 0px; margin: 0em; line-height: 12pt; padding-right: 0px; width: 100%; background-color: white"&gt;&lt;span id="lnum13" style="color: #606060"&gt;  13:&lt;/span&gt;       &lt;/pre&gt;
&lt;!--CRLF--&gt;&lt;/div&gt;
&lt;/div&gt;

&lt;div&gt; &lt;/div&gt;

&lt;div&gt;In this method we are checking if the &lt;strong&gt;VarByParam&lt;/strong&gt; is set to “&lt;strong&gt;data&lt;/strong&gt;” – it can be any value but if you want to control different caching on different pages then the name filters our caching options.&lt;/div&gt;

&lt;div&gt; &lt;/div&gt;

&lt;div&gt;Next we check if there is a parameter passed on the request query string set to &lt;strong&gt;NoCache&lt;/strong&gt; but this could be any parameter you want to check like search etc.&lt;/div&gt;

&lt;div&gt; &lt;/div&gt;

&lt;div&gt;We do not care about the value for &lt;strong&gt;NoCache&lt;/strong&gt; just that it exists and if it does then we return a new GUID as a string – this will cause a unique value to be returned to the caching engine and hence the result will be unique. Technically is is still cached but since we will never get another GUID with the same value it does not matter. It will however consume some server resources while your app pool is running.&lt;/div&gt;

&lt;div&gt; &lt;/div&gt;

&lt;div /&gt;&lt;img src="http://blog.crowe.co.nz/blog/aggbug/937.aspx" width="1" height="1" /&gt;</description>
            <dc:creator>Chris Crowe</dc:creator>
            <guid>http://blog.crowe.co.nz/blog/archive/2013/04/17/test-post.aspx</guid>
            <pubDate>Tue, 16 Apr 2013 22:36:13 GMT</pubDate>
            <comments>http://blog.crowe.co.nz/blog/archive/2013/04/17/test-post.aspx#feedback</comments>
            <wfw:commentRss>http://blog.crowe.co.nz/blog/comments/commentRss/937.aspx</wfw:commentRss>
        </item>
        <item>
            <title>Using the SQL Server Dedicated Admin Connection</title>
            <link>http://blog.crowe.co.nz/blog/archive/2012/07/04/using-the-sql-server-dedicated-admin-connection.aspx</link>
            <description>&lt;p&gt;I installed a test install of SharePoint 2010 Foundation for myself today at work . As part of the installation it installed an instance of SQL Server Express 2008 with SP1.&lt;/p&gt;  &lt;p&gt;I then installed SQL Server Management studio so I could administer the Database.&lt;/p&gt;  &lt;p&gt;I then noticed that the only user accounts under the security\logins section was:    &lt;br /&gt;&lt;/p&gt;  &lt;ul&gt;   &lt;li&gt;BUILTIN\Users &lt;/li&gt;    &lt;li&gt;sa &lt;/li&gt; &lt;/ul&gt;  &lt;p&gt;&lt;a href="http://blog.crowe.co.nz/images/blog_crowe_co_nz/Windows-Live-Writer/46149d27ce19_9002/image_thumb1_2.png"&gt;&lt;img style="background-image: none; border-bottom: 0px; border-left: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="image_thumb1" border="0" alt="image_thumb1" src="http://blog.crowe.co.nz/images/blog_crowe_co_nz/Windows-Live-Writer/46149d27ce19_9002/image_thumb1_thumb.png" width="434" height="421" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;SQL Server was also installed with Windows Only Authentication so the &lt;strong&gt;SA account &lt;/strong&gt;being a SQL Server Account was disabled (not that I would know the password anyway)&lt;/p&gt;  &lt;p&gt;&lt;a href="http://blog.crowe.co.nz/images/blog_crowe_co_nz/Windows-Live-Writer/46149d27ce19_9002/image_thumb3_2.png"&gt;&lt;img style="background-image: none; border-bottom: 0px; border-left: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="image_thumb3" border="0" alt="image_thumb3" src="http://blog.crowe.co.nz/images/blog_crowe_co_nz/Windows-Live-Writer/46149d27ce19_9002/image_thumb3_thumb.png" width="488" height="174" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;So the problem is how to sort this out so my domain user account could be added to the server.&lt;/p&gt;  &lt;p&gt;A bit of googleing bought around some help but it took a bit of work to sort it out for me so I thought I should write this up.&lt;/p&gt;  &lt;p&gt;SQL Server 2005+ provides a special diagnostic connection for administrators when standard connections to the server are not possible. This diagnostic connection allows an administrator to access SQL Server to execute diagnostic queries and troubleshoot problems even when SQL Server is not responding to standard connection requests.&lt;/p&gt;  &lt;p&gt;This dedicated administrator connection (DAC) supports encryption and other security features of SQL Server. SQL Server makes every attempt to make DAC connect successfully, but under extreme situations it may not be successful.&lt;/p&gt;  &lt;p&gt;SQL Server prohibits running parallel queries or commands with the DAC&lt;/p&gt;  &lt;p&gt;The process we will use to add an account to SQL Server is listed below and should take about 5 minutes to complete.&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;Step #1&lt;/strong&gt;&lt;/p&gt;  &lt;p&gt;On the SQL Server computer add your user account to the Local Administrators group – if you are a member of the local administrators group you will be able to connect to SQL Server using the Dedicated Admin Connection. &lt;/p&gt;  &lt;p&gt;&lt;strong&gt;Step #2&lt;/strong&gt;&lt;/p&gt;  &lt;p&gt;Open SQL Server Configuration Manager and disable SQL Server Services (you can also do this via the services applet)&lt;/p&gt;  &lt;p&gt;&lt;a href="http://blog.crowe.co.nz/images/blog_crowe_co_nz/Windows-Live-Writer/46149d27ce19_9002/image_thumb7_2.png"&gt;&lt;img style="background-image: none; border-bottom: 0px; border-left: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="image_thumb7" border="0" alt="image_thumb7" src="http://blog.crowe.co.nz/images/blog_crowe_co_nz/Windows-Live-Writer/46149d27ce19_9002/image_thumb7_thumb.png" width="780" height="202" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;Step #3&lt;/strong&gt;&lt;/p&gt;  &lt;p&gt;Start SQL Server Browser Service &lt;/p&gt;  &lt;p&gt;&lt;a href="http://blog.crowe.co.nz/images/blog_crowe_co_nz/Windows-Live-Writer/46149d27ce19_9002/image_thumb8_2.png"&gt;&lt;img style="background-image: none; border-bottom: 0px; border-left: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="image_thumb8" border="0" alt="image_thumb8" src="http://blog.crowe.co.nz/images/blog_crowe_co_nz/Windows-Live-Writer/46149d27ce19_9002/image_thumb8_thumb.png" width="188" height="171" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;Note: &lt;/strong&gt;If you right click in the SQL Server Configuration Manager and all options are disabled this means the service is disabled in the Services applet.&lt;/p&gt;  &lt;p&gt;Open the Services applet (Press &lt;strong&gt;Windows Key + R&lt;/strong&gt; and type in &lt;strong&gt;services.msc&lt;/strong&gt; and hit enter)&lt;/p&gt;  &lt;p&gt;Select the “SQL Server Browser” Service and Right-Click and select Properties&lt;/p&gt;    &lt;p&gt;&lt;a href="http://blog.crowe.co.nz/images/blog_crowe_co_nz/Windows-Live-Writer/46149d27ce19_9002/image_thumb10_2.png"&gt;&lt;img style="background-image: none; border-bottom: 0px; border-left: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="image_thumb10" border="0" alt="image_thumb10" src="http://blog.crowe.co.nz/images/blog_crowe_co_nz/Windows-Live-Writer/46149d27ce19_9002/image_thumb10_thumb.png" width="584" height="83" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;Change the service start-up to be &lt;strong&gt;Manual &lt;/strong&gt;and then click the apply button. Then click on the &lt;strong&gt;Start button&lt;/strong&gt; to start the service and OK to close the dialog.&lt;/p&gt;  &lt;p&gt;&lt;a href="http://blog.crowe.co.nz/images/blog_crowe_co_nz/Windows-Live-Writer/46149d27ce19_9002/image_thumb12_2.png"&gt;&lt;img style="background-image: none; border-bottom: 0px; border-left: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="image_thumb12" border="0" alt="image_thumb12" src="http://blog.crowe.co.nz/images/blog_crowe_co_nz/Windows-Live-Writer/46149d27ce19_9002/image_thumb12_thumb.png" width="414" height="463" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;&lt;em&gt;&lt;strong&gt;Note: If the SQL Server Browser service is not running the dedicated admin connection will not connect!&lt;/strong&gt;&lt;/em&gt;&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;Step #4&lt;/strong&gt;&lt;/p&gt;  &lt;p&gt;Open two instances of CMD.EXE – &lt;font style="background-color: #ffff00"&gt;MAKE SURE THEY ARE BOTH STARTED USING RUN AS ADMINISTRATOR&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;a href="http://blog.crowe.co.nz/images/blog_crowe_co_nz/Windows-Live-Writer/46149d27ce19_9002/image_thumb14_2.png"&gt;&lt;img style="background-image: none; border-bottom: 0px; border-left: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="image_thumb14" border="0" alt="image_thumb14" src="http://blog.crowe.co.nz/images/blog_crowe_co_nz/Windows-Live-Writer/46149d27ce19_9002/image_thumb14_thumb.png" width="329" height="211" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;We will use one of the command prompts to start SQL Server in console mode and the other we will use to connect to the SQL Server instance on the dedicated admin connection.&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;Step #5&lt;/strong&gt;&lt;/p&gt;  &lt;p&gt;In both command prompts change the default directory to the SQL Server BINN folder. This is dependant on your instance but something like this.&lt;/p&gt;  &lt;p&gt;&lt;a href="http://blog.crowe.co.nz/images/blog_crowe_co_nz/Windows-Live-Writer/46149d27ce19_9002/image_thumb16_2.png"&gt;&lt;img style="background-image: none; border-bottom: 0px; border-left: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="image_thumb16" border="0" alt="image_thumb16" src="http://blog.crowe.co.nz/images/blog_crowe_co_nz/Windows-Live-Writer/46149d27ce19_9002/image_thumb16_thumb.png" width="668" height="92" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;Step #6&lt;/strong&gt;&lt;/p&gt;  &lt;p&gt;Start SQL Server with one of the CMD.EXE command prompts enabling the dedicated Admin Connection&lt;/p&gt;  &lt;p&gt;The command I used was:&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;sqlservr.exe –sSharePoint -T 7806&lt;/strong&gt;&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;The Trace Flag 7806 Enables a dedicated administrator connection (DAC) on SQL Server Express. By default, no DAC resources are reserved on SQL Server Express.&lt;/strong&gt;&lt;/p&gt;  &lt;p&gt;See &lt;a title="http://msdn.microsoft.com/en-us/library/ms188396.aspx" href="http://msdn.microsoft.com/en-us/library/ms188396.aspx"&gt;http://msdn.microsoft.com/en-us/library/ms188396.aspx&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;In my case I was connecting to an SQL Server Instance called “&lt;strong&gt;SharePoint&lt;/strong&gt;”&lt;/p&gt;  &lt;p&gt;&lt;a href="http://blog.crowe.co.nz/images/blog_crowe_co_nz/Windows-Live-Writer/46149d27ce19_9002/image_thumb23_2.png"&gt;&lt;img style="background-image: none; border-bottom: 0px; border-left: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="image_thumb23" border="0" alt="image_thumb23" src="http://blog.crowe.co.nz/images/blog_crowe_co_nz/Windows-Live-Writer/46149d27ce19_9002/image_thumb23_thumb.png" width="873" height="96" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;Here is the full log that was created from running the command above.&lt;/p&gt;  &lt;div style="font-family: courier; font-size: 8pt"&gt;   &lt;p&gt;2011-09-14 16:17:19.98 Server Microsoft SQL Server 2008 (SP1) - 10.0.2531.0 (X64)      &lt;br /&gt;Mar 29 2009 10:11:52       &lt;br /&gt;Copyright (c) 1988-2008 Microsoft Corporation       &lt;br /&gt;Express Edition (64-bit) on Windows NT 6.1 &amp;lt;X64&amp;gt; (Build 7601: Service Pack 1) (VM)       &lt;br /&gt;      &lt;br /&gt;2011-09-14 16:17:19.98 Server (c) 2005 Microsoft Corporation.       &lt;br /&gt;2011-09-14 16:17:19.98 Server All rights reserved.       &lt;br /&gt;2011-09-14 16:17:19.98 Server Server process ID is 3840.       &lt;br /&gt;2011-09-14 16:17:19.98 Server System Manufacturer: 'VMware, Inc.', System Model: 'VMware Virtual Platform'.       &lt;br /&gt;2011-09-14 16:17:19.98 Server Authentication mode is WINDOWS-ONLY.       &lt;br /&gt;2011-09-14 16:17:19.98 Server Logging SQL Server messages in file 'e:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\14\Data\MSSQL10.SHAREPOINT\MSSQL\Log\ERRORLOG'.       &lt;br /&gt;2011-09-14 16:17:19.98 Server This instance of SQL Server last reported using a process ID of 1776 at 9/14/2011 4:17:17 PM (local) 9/14/2011 4:17:17 AM (UTC). This is an informational message only; no user action is required.       &lt;br /&gt;2011-09-14 16:17:19.98 Server Registry startup parameters:       &lt;br /&gt;-d e:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\14\Data\MSSQL10.SHAREPOINT\MSSQL\DATA\master.mdf       &lt;br /&gt;-e e:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\14\Data\MSSQL10.SHAREPOINT\MSSQL\Log\ERRORLOG       &lt;br /&gt;-l e:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\14\Data\MSSQL10.SHAREPOINT\MSSQL\DATA\mastlog.ldf       &lt;br /&gt;2011-09-14 16:17:19.98 Server Command Line Startup Parameters:       &lt;br /&gt;-s Sharepoint       &lt;br /&gt;-T 7806       &lt;br /&gt;7806       &lt;br /&gt;2011-09-14 16:17:20.00 Server SQL Server is starting at normal priority base (=7). This is an informational message only. No user action is required.       &lt;br /&gt;2011-09-14 16:17:20.00 Server Detected 4 CPUs. This is an informational message; no user action is required.       &lt;br /&gt;2011-09-14 16:17:20.05 Server Using dynamic lock allocation. Initial allocation of 2500 Lock blocks and 5000 Lock Owner blocks per node. This is an informational message only. No user action is required.       &lt;br /&gt;2011-09-14 16:17:20.07 Server Node configuration: node 0: CPU mask: 0x0000000000000001 Active CPU mask: 0x0000000000000001. This message provides a description of the NUMA configuration for this computer. This is an informational message only. No user action is required.       &lt;br /&gt;2011-09-14 16:17:20.10 spid7s Starting up database 'master'.       &lt;br /&gt;2011-09-14 16:17:20.18 spid7s 6 transactions rolled forward in database 'master' (1). This is an informational message only. No user action is required.       &lt;br /&gt;2011-09-14 16:17:20.21 spid7s 0 transactions rolled back in database 'master' (1). This is an informational message only. No user action is required.       &lt;br /&gt;2011-09-14 16:17:20.21 spid7s Recovery is writing a checkpoint in database 'master' (1). This is an informational message only. No user action is required.       &lt;br /&gt;2011-09-14 16:17:20.34 spid7s FILESTREAM: effective level = 0, configured level = 0, file system access share name = 'SHAREPOINT'.       &lt;br /&gt;2011-09-14 16:17:20.37 spid7s SQL Trace ID 1 was started by login "sa".       &lt;br /&gt;2011-09-14 16:17:20.38 spid7s Starting up database 'mssqlsystemresource'.       &lt;br /&gt;2011-09-14 16:17:20.40 spid7s The resource database build version is 10.00.2531. This is an informational message only. No user action is required.       &lt;br /&gt;2011-09-14 16:17:20.82 spid7s Server name is 'CHRIS-SHAREPOIN\SHAREPOINT'. This is an informational message only. No user action is required.       &lt;br /&gt;2011-09-14 16:17:20.82 spid10s Starting up database 'model'.       &lt;br /&gt;2011-09-14 16:17:20.82 spid7s Informational: No full-text supported languages found.       &lt;br /&gt;2011-09-14 16:17:20.83 spid7s Starting up database 'msdb'.       &lt;br /&gt;2011-09-14 16:17:20.83 Server A self-generated certificate was successfully loaded for encryption.       &lt;br /&gt;2011-09-14 16:17:20.83 Server Server is listening on [ 'any' &amp;lt;ipv6&amp;gt; 62035].       &lt;br /&gt;2011-09-14 16:17:20.83 Server Server is listening on [ 'any' &amp;lt;ipv4&amp;gt; 62035].       &lt;br /&gt;2011-09-14 16:17:20.83 Server Server local connection provider is ready to accept connection on [ \\.\pipe\SQLLocal\SHAREPOINT ].       &lt;br /&gt;2011-09-14 16:17:20.84 Server Server local connection provider is ready to accept connection on [ \\.\pipe\MSSQL$SHAREPOINT\sql\query ].       &lt;br /&gt;2011-09-14 16:17:20.84 Server Server is listening on [ ::1 &amp;lt;ipv6&amp;gt; 62042].       &lt;br /&gt;2011-09-14 16:17:20.84 Server Server is listening on [ 127.0.0.1 &amp;lt;ipv4&amp;gt; 62042].       &lt;br /&gt;2011-09-14 16:17:20.84 Server &lt;font style="background-color: #ffff00"&gt;Dedicated admin connection support was established for listening locally on port 62042.&lt;/font&gt;       &lt;br /&gt;2011-09-14 16:17:20.86 Server The SQL Server Network Interface library successfully registered the Service Principal Name (SPN) [ MSSQLSvc/Chris-sharepoin.DOMAIN:SHAREPOINT ] for the SQL Server service.       &lt;br /&gt;2011-09-14 16:17:20.86 Server The SQL Server Network Interface library successfully registered the Service Principal Name (SPN) [ MSSQLSvc/Chris-sharepoin.DOMAIN:62035 ] for the SQL Server service.       &lt;br /&gt;2011-09-14 16:17:20.86 Server SQL Server is now ready for client connections. This is an informational message; no user action is required.       &lt;br /&gt;2011-09-14 16:17:20.91 spid10s Clearing tempdb database.       &lt;br /&gt;2011-09-14 16:17:21.06 spid10s Starting up database 'tempdb'.       &lt;br /&gt;2011-09-14 16:17:21.13 spid13s The Service Broker protocol transport is disabled or not configured.       &lt;br /&gt;2011-09-14 16:17:21.13 spid13s The Database Mirroring protocol transport is disabled or not configured.       &lt;br /&gt;2011-09-14 16:17:21.16 spid13s Service Broker manager has started.       &lt;br /&gt;2011-09-14 16:17:21.46 spid7s 1 transactions rolled forward in database 'msdb' (4). This is an informational message only. No user action is required.       &lt;br /&gt;2011-09-14 16:17:21.48 spid7s 0 transactions rolled back in database 'msdb' (4). This is an informational message only. No user action is required.       &lt;br /&gt;2011-09-14 16:17:21.48 spid7s Recovery is writing a checkpoint in database 'msdb' (4). This is an informational message only. No user action is required.       &lt;br /&gt;2011-09-14 16:17:21.51 spid7s Recovery is complete. This is an informational message only. No user action is required.       &lt;br /&gt;2011-09-14 16:17:28.68 spid7s SQL Server shutdown due to Ctrl-C or Ctrl-Break signal. This is an informational message only. No user action is required.       &lt;br /&gt;2011-09-14 16:17:28.68 spid7s SQL Trace was stopped due to server shutdown. Trace ID = '1'. This is an informational message only; no user action is required.       &lt;br /&gt;2011-09-14 16:17:28.70 Server The SQL Server Network Interface library successfully deregistered the Service Principal Name (SPN) [ MSSQLSvc/Chris-sharepoin.DOMAIN:SHAREPOINT ] for the SQL Server service.       &lt;br /&gt;2011-09-14 16:17:28.70 Server The SQL Server Network Interface library successfully deregistered the Service Principal Name (SPN) [ MSSQLSvc/Chris-sharepoin.DOMAIN:62035 ] for the SQL Server service.       &lt;br /&gt;&lt;/p&gt; &lt;/div&gt;  &lt;p&gt;&lt;strong&gt;Step #7&lt;/strong&gt;&lt;/p&gt;  &lt;p&gt;create Go to the second command prompt and enter the following command to login using the dedicated admin connection.&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;SQLCMD.EXE –Sadmin:.\SharePoint&lt;/strong&gt;&lt;/p&gt;  &lt;p&gt;The –S command is for the server name, the &lt;strong&gt;admin:&lt;/strong&gt; means to use the admin connection and the .\SharePoint is the server (.) and Instance name (SharePoint)&lt;/p&gt;  &lt;p&gt;&lt;a href="http://blog.crowe.co.nz/images/blog_crowe_co_nz/Windows-Live-Writer/46149d27ce19_9002/image_thumb18_2.png"&gt;&lt;img style="background-image: none; border-bottom: 0px; border-left: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="image_thumb18" border="0" alt="image_thumb18" src="http://blog.crowe.co.nz/images/blog_crowe_co_nz/Windows-Live-Writer/46149d27ce19_9002/image_thumb18_thumb.png" width="672" height="106" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;If all is good then you should see a 1&amp;gt; &lt;/strong&gt;&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;&lt;font style="background-color: #ffff00"&gt;If you do not see the 1&amp;gt; ensure the SQL Server Browser service is running&lt;/font&gt;.&lt;/strong&gt;&lt;/p&gt;  &lt;p&gt;Now you can create a login to SQL Server and add that login to the SYSADMIN role.&lt;/p&gt;  &lt;p&gt;To do that type in &lt;/p&gt;  &lt;p&gt;&lt;strong&gt;&lt;em&gt;CREATE LOGIN [DOMAIN\USERNAME] from WINDOWS        &lt;br /&gt;GO&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;  &lt;p&gt;and then&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;&lt;em&gt;exec SP_ADDSRVROLEMEMBER ‘DOMAIN\USERNAME’, ‘sysadmin’        &lt;br /&gt;GO&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;  &lt;p&gt;&lt;a href="http://blog.crowe.co.nz/images/blog_crowe_co_nz/Windows-Live-Writer/46149d27ce19_9002/image_thumb21_2.png"&gt;&lt;img style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="image_thumb21" border="0" alt="image_thumb21" src="http://blog.crowe.co.nz/images/blog_crowe_co_nz/Windows-Live-Writer/46149d27ce19_9002/image_thumb21_thumb.png" width="684" height="164" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;Now you should have your domain account in the SYSADMIN role.&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;Step #8&lt;/strong&gt;&lt;/p&gt;  &lt;p&gt;To finish we need to restore the original configuration for the services and restart SQL Server as a service&lt;/p&gt;  &lt;p&gt;You can now press CTRL-C to stop the SQL Server instance that is running in the command prompt.&lt;/p&gt;  &lt;p&gt;Go back to the services applet and if appropriate disable the SQL Server Browser service.&lt;/p&gt;  &lt;p align="left"&gt;Start the SQL Server Services that you had running as well using the Services applet.&lt;/p&gt;&lt;img src="http://blog.crowe.co.nz/blog/aggbug/936.aspx" width="1" height="1" /&gt;</description>
            <dc:creator>Chris Crowe</dc:creator>
            <guid>http://blog.crowe.co.nz/blog/archive/2012/07/04/using-the-sql-server-dedicated-admin-connection.aspx</guid>
            <pubDate>Tue, 03 Jul 2012 22:14:23 GMT</pubDate>
            <comments>http://blog.crowe.co.nz/blog/archive/2012/07/04/using-the-sql-server-dedicated-admin-connection.aspx#feedback</comments>
            <slash:comments>148</slash:comments>
            <wfw:commentRss>http://blog.crowe.co.nz/blog/comments/commentRss/936.aspx</wfw:commentRss>
        </item>
        <item>
            <title>Google Maps&amp;ndash;without the labels</title>
            <link>http://blog.crowe.co.nz/blog/archive/2012/07/04/google-mapsndashwithout-the-labels.aspx</link>
            <description>&lt;p&gt;Some times it is nice to have a clean map without any labels all over the map.&lt;/p&gt;  &lt;p&gt;You can do this with just a small bit of code and it works for the standard Map, Satellite and Terrain models.&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;Map Examples&lt;/strong&gt;&lt;/p&gt;  &lt;p&gt;&lt;a href="http://blog.crowe.co.nz/images/blog_crowe_co_nz/Windows-Live-Writer/Google-Mapswithout-the_8538/image_2.png"&gt;&lt;img style="background-image: none; border-right-width: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px" title="image" border="0" alt="image" src="http://blog.crowe.co.nz/images/blog_crowe_co_nz/Windows-Live-Writer/Google-Mapswithout-the_8538/image_thumb.png" width="244" height="138" /&gt;&lt;/a&gt;  &lt;a href="http://blog.crowe.co.nz/images/blog_crowe_co_nz/Windows-Live-Writer/Google-Mapswithout-the_8538/image_8.png"&gt;&lt;img style="background-image: none; border-right-width: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px" title="image" border="0" alt="image" src="http://blog.crowe.co.nz/images/blog_crowe_co_nz/Windows-Live-Writer/Google-Mapswithout-the_8538/image_thumb_3.png" width="234" height="138" /&gt;&lt;/a&gt;  &lt;a href="http://blog.crowe.co.nz/images/blog_crowe_co_nz/Windows-Live-Writer/Google-Mapswithout-the_8538/image_6.png"&gt;&lt;img style="background-image: none; border-right-width: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px" title="image" border="0" alt="image" src="http://blog.crowe.co.nz/images/blog_crowe_co_nz/Windows-Live-Writer/Google-Mapswithout-the_8538/image_thumb_2.png" width="244" height="136" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;For a live example see &lt;/p&gt;  &lt;p&gt;&lt;a title="http://weather.crowe.co.nz/mapdemo" href="http://weather.crowe.co.nz/mapdemo"&gt;http://weather.crowe.co.nz/mapdemo&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;Basically we just add some custom layers and control the urls’s that are used.&lt;/p&gt;  &lt;pre class="csharpcode"&gt; &amp;lt;script type=&lt;span class="str"&gt;"text/javascript"&lt;/span&gt;&amp;gt;
        &lt;span class="kwrd"&gt;var&lt;/span&gt; map = &lt;span class="kwrd"&gt;null&lt;/span&gt;;

        &lt;span class="kwrd"&gt;function&lt;/span&gt; CustomMap(name, alt, baseUrlIndex) {
            CustomMap.prototype.baseUrls =
               [
                    [&lt;span class="str"&gt;"http://mt0.google.com"&lt;/span&gt;, &lt;span class="str"&gt;"http://mt1.google.com"&lt;/span&gt;, &lt;span class="str"&gt;"http://mt2.google.com"&lt;/span&gt;, &lt;span class="str"&gt;"http://mt3.google.com"&lt;/span&gt;],  &lt;span class="rem"&gt;// MAP&lt;/span&gt;
                    [&lt;span class="str"&gt;"http://khms0.google.com"&lt;/span&gt;, &lt;span class="str"&gt;"http://khms1.google.com"&lt;/span&gt;, &lt;span class="str"&gt;"http://khms2.google.com"&lt;/span&gt;, &lt;span class="str"&gt;"http://khms3.google.com"&lt;/span&gt;], &lt;span class="rem"&gt;// Satellite&lt;/span&gt;
                    [&lt;span class="str"&gt;"http://mts0.google.com"&lt;/span&gt;, &lt;span class="str"&gt;"http://mts1.google.com"&lt;/span&gt;, &lt;span class="str"&gt;"http://mts2.google.com"&lt;/span&gt;, &lt;span class="str"&gt;"http://mts3.google.com"&lt;/span&gt;]  &lt;span class="rem"&gt;// Terrain&lt;/span&gt;
               ];

            CustomMap.prototype.partUrls =
                [&lt;span class="str"&gt;"/vt/lyrs=m@164000000,weather_nolabels&amp;amp;hl=en&amp;amp;x="&lt;/span&gt;, &lt;span class="str"&gt;"/kh/v=113&amp;amp;src=app&amp;amp;x="&lt;/span&gt;, &lt;span class="str"&gt;"/vt/lyrs=t@128,r@179000000,weather_nolabels&amp;amp;hl=en&amp;amp;x="&lt;/span&gt;];

            CustomMap.prototype.tileSize = &lt;span class="kwrd"&gt;new&lt;/span&gt; google.maps.Size(256, 256);
            CustomMap.prototype.maxZoom = 19;

            &lt;span class="kwrd"&gt;this&lt;/span&gt;.alt = alt;
            &lt;span class="kwrd"&gt;this&lt;/span&gt;.name = name;
            &lt;span class="kwrd"&gt;this&lt;/span&gt;.baseUrlIndex = baseUrlIndex;
        }

        CustomMap.prototype.getTile = &lt;span class="kwrd"&gt;function&lt;/span&gt; (coord, zoom, ownerDocument) {
            &lt;span class="kwrd"&gt;var&lt;/span&gt; MaxTilesAtThisZoomLevel = Math.pow(2, zoom);
            &lt;span class="kwrd"&gt;var&lt;/span&gt; x = coord.x % MaxTilesAtThisZoomLevel;

            &lt;span class="kwrd"&gt;var&lt;/span&gt; i = (x + 2 * coord.y) % &lt;span class="kwrd"&gt;this&lt;/span&gt;.baseUrls[&lt;span class="kwrd"&gt;this&lt;/span&gt;.baseUrlIndex].length;
            &lt;span class="kwrd"&gt;var&lt;/span&gt; salt = &lt;span class="str"&gt;"Galileo"&lt;/span&gt;.substr(0, (x * 3 + coord.y) % 8);
            &lt;span class="kwrd"&gt;var&lt;/span&gt; URL = [&lt;span class="kwrd"&gt;this&lt;/span&gt;.baseUrls[&lt;span class="kwrd"&gt;this&lt;/span&gt;.baseUrlIndex][i], &lt;span class="kwrd"&gt;this&lt;/span&gt;.partUrls[&lt;span class="kwrd"&gt;this&lt;/span&gt;.baseUrlIndex], x, &lt;span class="str"&gt;"&amp;amp;y="&lt;/span&gt;, coord.y, &lt;span class="str"&gt;"&amp;amp;z="&lt;/span&gt;, zoom, &lt;span class="str"&gt;"&amp;amp;s="&lt;/span&gt;, salt].join(&lt;span class="str"&gt;""&lt;/span&gt;);

            &lt;span class="kwrd"&gt;var&lt;/span&gt; div = ownerDocument.createElement(&lt;span class="str"&gt;'IMG'&lt;/span&gt;);
            div.src = URL;
            div.style.width = &lt;span class="kwrd"&gt;this&lt;/span&gt;.tileSize.width + &lt;span class="str"&gt;'px'&lt;/span&gt;;
            div.style.height = &lt;span class="kwrd"&gt;this&lt;/span&gt;.tileSize.height + &lt;span class="str"&gt;'px'&lt;/span&gt;;
            &lt;span class="kwrd"&gt;return&lt;/span&gt; div;
        };

        $(document).ready(&lt;span class="kwrd"&gt;function&lt;/span&gt; () {

            &lt;span class="kwrd"&gt;var&lt;/span&gt; myOptions =
                            {
                                zoom: 12,
                                minZoom: 3,
                                center: &lt;span class="kwrd"&gt;new&lt;/span&gt; google.maps.LatLng(-43.53, 172.6),
                                mapTypeId: &lt;span class="str"&gt;'mapNoNames'&lt;/span&gt;,
                                mapTypeControlOptions: {
                                    mapTypeIds: [&lt;span class="str"&gt;'mapNoNames'&lt;/span&gt;, &lt;span class="str"&gt;'SatelliteNoNames'&lt;/span&gt;, &lt;span class="str"&gt;'TerrainNoNames'&lt;/span&gt;],
                                    style: google.maps.MapTypeControlStyle.DROPDOWN_MENU
                                }
                            };
            map = &lt;span class="kwrd"&gt;new&lt;/span&gt; google.maps.Map(document.getElementById(&lt;span class="str"&gt;"map_canvas"&lt;/span&gt;), myOptions);

            map.mapTypes.set(&lt;span class="str"&gt;'mapNoNames'&lt;/span&gt;, &lt;span class="kwrd"&gt;new&lt;/span&gt; CustomMap(&lt;span class="str"&gt;"Map"&lt;/span&gt;, &lt;span class="str"&gt;"Map"&lt;/span&gt;, 0));
            map.mapTypes.set(&lt;span class="str"&gt;'SatelliteNoNames'&lt;/span&gt;, &lt;span class="kwrd"&gt;new&lt;/span&gt; CustomMap(&lt;span class="str"&gt;"Satellite"&lt;/span&gt;, &lt;span class="str"&gt;"Satellite"&lt;/span&gt;, 1));
            map.mapTypes.set(&lt;span class="str"&gt;'TerrainNoNames'&lt;/span&gt;, &lt;span class="kwrd"&gt;new&lt;/span&gt; CustomMap(&lt;span class="str"&gt;"Terrain"&lt;/span&gt;, &lt;span class="str"&gt;"Terrain"&lt;/span&gt;, 2));


        });

    &amp;lt;/script&amp;gt;&lt;/pre&gt;
&lt;style type="text/css"&gt;&lt;![CDATA[

.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }]]&gt;&lt;/style&gt;&lt;img src="http://blog.crowe.co.nz/blog/aggbug/935.aspx" width="1" height="1" /&gt;</description>
            <dc:creator>Chris Crowe</dc:creator>
            <guid>http://blog.crowe.co.nz/blog/archive/2012/07/04/google-mapsndashwithout-the-labels.aspx</guid>
            <pubDate>Tue, 03 Jul 2012 21:59:16 GMT</pubDate>
            <comments>http://blog.crowe.co.nz/blog/archive/2012/07/04/google-mapsndashwithout-the-labels.aspx#feedback</comments>
            <slash:comments>104</slash:comments>
            <wfw:commentRss>http://blog.crowe.co.nz/blog/comments/commentRss/935.aspx</wfw:commentRss>
        </item>
        <item>
            <title>Microsoft Office Outlook has encountered a problem and needs to close when opening email messages</title>
            <link>http://blog.crowe.co.nz/blog/archive/2010/11/03/Outlook-2010-crashes-when-opening-some-email-messages.aspx</link>
            <description>&lt;p&gt;I recently has a user who found that email messages from specific people would cause her Outlook 2010 to crash 100% of the time. Most peoples emails were perfectly fine and others were not.&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;There were lots of entries in the Windows Event Log like the following&lt;/strong&gt;&lt;/p&gt;  &lt;blockquote&gt;   &lt;p&gt;Faulting application name: OUTLOOK.EXE, version: 14.0.4760.1000, time stamp: 0x4ba8fefd &lt;/p&gt;    &lt;p&gt;Faulting module name: USP10.DLL, version: 1.626.7600.20602, time stamp: 0x4b304c27 &lt;/p&gt;    &lt;p&gt;Exception code: 0xc0000005 &lt;/p&gt;    &lt;p&gt;Fault offset: 0x00027466 &lt;/p&gt;    &lt;p&gt;Faulting process id: 0xa38 &lt;/p&gt;    &lt;p&gt;Faulting application start time: 0x01cb6ef5e0cefe77 &lt;/p&gt;    &lt;p&gt;Faulting application path: C:\Program Files (x86)\Microsoft Office\Office14\OUTLOOK.EXE &lt;/p&gt;    &lt;p&gt;Faulting module path: C:\Program Files (x86)\Common Files\Microsoft Shared\OFFICE14\USP10.DLL&lt;/p&gt; &lt;/blockquote&gt;  &lt;p&gt;I read up online and found this article &lt;a title="http://social.technet.microsoft.com/Forums/en-US/outlook/thread/178bce4f-707e-42ac-8743-ac41b7a4e046/" href="http://social.technet.microsoft.com/Forums/en-US/outlook/thread/178bce4f-707e-42ac-8743-ac41b7a4e046/"&gt;http://social.technet.microsoft.com/Forums/en-US/outlook/thread/178bce4f-707e-42ac-8743-ac41b7a4e046/&lt;/a&gt; where a lot of people where having a similar problem.&lt;/p&gt;  &lt;p&gt;There were lot of opinions given there and they did nothing to help me fix the problem directly.&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;Microsoft&lt;/strong&gt;&lt;/p&gt;  &lt;p&gt;I ended up opening a case with Microsoft and together over a period of a week we diagnosed the problem.&lt;/p&gt;  &lt;p&gt;The problem was – &lt;strong&gt;A Corrupt Font&lt;/strong&gt;&lt;/p&gt;  &lt;p&gt;I found a few posts online which referred to Helvetica Font (above link and also other places) being corrupt and causing problems with Outlook. &lt;/p&gt;  &lt;p&gt;But in my case it was an &lt;strong&gt;Arial Narrow font.&lt;/strong&gt;&lt;/p&gt;  &lt;p&gt;&lt;em&gt;* I have suggested that Microsoft Write a tool to test all fonts for corruption – who knows what will happen.&lt;/em&gt;&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;&lt;/strong&gt;&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;One of the responses from Microsoft was&lt;/strong&gt;&lt;/p&gt;  &lt;p&gt;Based on my research I found that the affected emails which you sent to me is in Helvetica font. Looks like the issue is specific to Helvetica font.&lt;/p&gt;  &lt;p&gt;This problem may occur if your document contains Type 1 fonts, such as Helvetica and TimesNewRomanPS.    &lt;br /&gt;Note: The same problem can occur in Microsoft Office Outlook 2010 if an email message contains Type 1 fonts.&lt;/p&gt;  &lt;p&gt;To resolve this problem, please follow the action below.&lt;/p&gt;  &lt;p&gt;Determine which offending Type 1 font is being applied to your document, and then remove the offending Type 1 Font Substitutions entry from the registry. To do this, follow these steps: &lt;/p&gt;  &lt;ol&gt;   &lt;li&gt;Click &lt;b&gt;Start&lt;/b&gt;, type &lt;b&gt;regedit&lt;/b&gt; in the &lt;strong&gt;Start Search&lt;/strong&gt; box, and then press Enter. &lt;/li&gt; &lt;/ol&gt;  &lt;p&gt;Collapse this imageExpand this image&lt;/p&gt;  &lt;p&gt;If you are prompted for an administrator password or for confirmation, type the password, or provide confirmation. &lt;/p&gt;  &lt;ol&gt;   &lt;li&gt;In Registry Editor, locate the following subkey: &lt;/li&gt; &lt;/ol&gt;  &lt;p&gt;HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\FontSubstitutes&lt;/p&gt;  &lt;ol&gt;   &lt;li&gt;Under the &lt;strong&gt;FontSubstitutes&lt;/strong&gt; entry, select the offending Type 1 font. &lt;/li&gt;    &lt;li&gt;Right-click the font, and then click &lt;strong&gt;Delete&lt;/strong&gt;. &lt;/li&gt;    &lt;li&gt;Exit Registry Editor. &lt;/li&gt;    &lt;li&gt;Restart the computer. &lt;/li&gt;    &lt;li&gt;Uninstall the offending Type 1 fonts. For more information about how to uninstall fonts, see the following Microsoft Knowledge Base article: &lt;/li&gt; &lt;/ol&gt;  &lt;p&gt;&lt;a href="http://support.microsoft.com/kb/314960/"&gt;314960&lt;/a&gt; (http://support.microsoft.com/kb/314960/ ) How to install or remove a font in Windows&lt;/p&gt;  &lt;ol&gt;   &lt;li&gt;Install the OpenType versions of the offending Type 1 fonts. &lt;/li&gt; &lt;/ol&gt;  &lt;p&gt;For more detailed information, please refer to &lt;a href="http://support.microsoft.com/default.aspx?scid=kb;en-US;2119612"&gt;http://support.microsoft.com/default.aspx?scid=kb;en-US;2119612&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;** IMPORTANT ** The Microsoft response above did not fix the problem but more investigation showed that Arial fonts were the issue&lt;/strong&gt;&lt;/p&gt;  &lt;p&gt;This problem was on a Windows 7 machine (and mine was as well) so I decided to copy the Arial fonts from the bad machine to my machine. After this “I” got the problem as well!!! (I made a backup of the fonts first!)&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;The Fix (for me anyway) - Copy my good Arial Fonts to the bad computer&lt;/strong&gt;&lt;/p&gt;  &lt;p&gt;In order to resolve this I needed to copy the good fonts from my machine to a temp directory on my machine and then copy them to a temp folder on the bad machine and then copy the font from the temp folder to the Fonts applet.&lt;/p&gt;  &lt;p&gt;Normally using the Fonts applet you can not copy fonts to anywhere else, but by opening a CMD prompt you can make copies of them.&lt;/p&gt;  &lt;p&gt;&lt;a href="http://blog.crowe.co.nz/images/blog_crowe_co_nz/blog/WindowsLiveWriter/Outlook2010crasheswhenopeningsomeemailme_98BE/image_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="image" border="0" alt="image" src="http://blog.crowe.co.nz/images/blog_crowe_co_nz/blog/WindowsLiveWriter/Outlook2010crasheswhenopeningsomeemailme_98BE/image_thumb.png" width="641" height="351" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;So on the good computer open a CMD prompt and change directory to &lt;strong&gt;c:\windows\fonts&lt;/strong&gt;&lt;/p&gt;  &lt;p&gt;You can now copy the good fonts to another folder on the local machine such as c:\temp&lt;/p&gt;  &lt;p&gt;You now need to copy the fonts from the c:\temp folder to a folder on the bad computer – again c:\temp&lt;/p&gt;  &lt;p&gt;Then on the bad computer open the Fonts applet (you can just type &lt;strong&gt;fonts &lt;/strong&gt;and hit enter at the search programs and files area in the start menu)&lt;/p&gt;  &lt;p&gt;&lt;a href="http://blog.crowe.co.nz/images/blog_crowe_co_nz/blog/WindowsLiveWriter/Outlook2010crasheswhenopeningsomeemailme_98BE/image_4.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" src="http://blog.crowe.co.nz/images/blog_crowe_co_nz/blog/WindowsLiveWriter/Outlook2010crasheswhenopeningsomeemailme_98BE/image_thumb_1.png" width="705" height="513" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;Now with that window open you can drag the fonts from c:\temp to the fonts window and you will be prompted to overwrite any existing fonts (if copying more than one font you can let it overwrite all fonts)&lt;/p&gt;  &lt;p&gt;&lt;a href="http://blog.crowe.co.nz/images/blog_crowe_co_nz/blog/WindowsLiveWriter/Outlook2010crasheswhenopeningsomeemailme_98BE/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" src="http://blog.crowe.co.nz/images/blog_crowe_co_nz/blog/WindowsLiveWriter/Outlook2010crasheswhenopeningsomeemailme_98BE/image_thumb_2.png" width="370" height="165" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;&lt;strong&gt;Some thoughts&lt;/strong&gt;&lt;/p&gt;  &lt;p&gt;Now by the time I got around to checking these fonts we had sent 100’s of megabytes of debug logs to Microsoft, removed all add-ons, started in safe mode, rebooted heaps of times and generally spent a lot of time on the problem.&lt;/p&gt;  &lt;p&gt;I had been in contact with Microsoft on the phone and via email and a week or more time had passed with the user not being able to open emails from specific users.&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;I would assume you could copy all fonts from a known good machine to the bad computer. &lt;/strong&gt;If you copy all fonts you may never know what font was corrupt, but there is a good chance that in less than 5 minutes you will have a working Outlook again.&lt;/p&gt;  &lt;p&gt; &lt;/p&gt;  &lt;p&gt;&lt;strong&gt;Also See&lt;/strong&gt;&lt;/p&gt;  &lt;blockquote&gt;   &lt;p&gt;Microsoft Office Word has encountered a problem and needs to close      &lt;br /&gt;&lt;a title="http://support.microsoft.com/default.aspx?scid=kb;en-US;2119612" href="http://support.microsoft.com/default.aspx?scid=kb;en-US;2119612"&gt;http://support.microsoft.com/default.aspx?scid=kb;en-US;2119612&lt;/a&gt;       &lt;br /&gt;      &lt;br /&gt;Microsoft Forum on this topic       &lt;br /&gt;&lt;a title="http://social.technet.microsoft.com/Forums/en-US/outlook/thread/178bce4f-707e-42ac-8743-ac41b7a4e046/" href="http://social.technet.microsoft.com/Forums/en-US/outlook/thread/178bce4f-707e-42ac-8743-ac41b7a4e046/"&gt;http://social.technet.microsoft.com/Forums/en-US/outlook/thread/178bce4f-707e-42ac-8743-ac41b7a4e046/&lt;/a&gt;&lt;/p&gt;&lt;/blockquote&gt;&lt;img src="http://blog.crowe.co.nz/blog/aggbug/931.aspx" width="1" height="1" /&gt;</description>
            <dc:creator>Chris Crowe</dc:creator>
            <guid>http://blog.crowe.co.nz/blog/archive/2010/11/03/Outlook-2010-crashes-when-opening-some-email-messages.aspx</guid>
            <pubDate>Tue, 02 Nov 2010 20:52:10 GMT</pubDate>
            <comments>http://blog.crowe.co.nz/blog/archive/2010/11/03/Outlook-2010-crashes-when-opening-some-email-messages.aspx#feedback</comments>
            <slash:comments>76</slash:comments>
            <wfw:commentRss>http://blog.crowe.co.nz/blog/comments/commentRss/931.aspx</wfw:commentRss>
        </item>
        <item>
            <title>The row value(s) updated or deleted either do not make the row unique or they alter multiple rows.</title>
            <link>http://blog.crowe.co.nz/blog/archive/2010/08/30/The-row-values-updated-or-deleted-either-do-not-make.aspx</link>
            <description>&lt;p&gt;I had a user ask me today how they can delete a duplicate row from their database table. They were receiving the following error message when they tried to delete the duplicate row.&lt;/p&gt;  &lt;p&gt;&lt;i&gt;The row value&lt;/i&gt;(s) &lt;em&gt;updated or deleted either do not make the row unique or they alter multiple rows&lt;/em&gt;.&lt;/p&gt;  &lt;p&gt;The reason that the user gets this message is because the table did not have a Primary Key or other Unique Index defined. Why, that’s another story and not one I know!&lt;/p&gt;  &lt;p&gt;An example table&lt;/p&gt;  &lt;p&gt;&lt;a href="http://blog.crowe.co.nz/images/blog_crowe_co_nz/blog/WindowsLiveWriter/Therowvaluesupdatedordeletedeitherdonot_B59F/image_2.png"&gt;&lt;img style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="image" border="0" alt="image" src="http://blog.crowe.co.nz/images/blog_crowe_co_nz/blog/WindowsLiveWriter/Therowvaluesupdatedordeletedeitherdonot_B59F/image_thumb.png" width="344" height="107" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;Some example data&lt;/p&gt;  &lt;p&gt;&lt;a href="http://blog.crowe.co.nz/images/blog_crowe_co_nz/blog/WindowsLiveWriter/Therowvaluesupdatedordeletedeitherdonot_B59F/image_4.png"&gt;&lt;img style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="image" border="0" alt="image" src="http://blog.crowe.co.nz/images/blog_crowe_co_nz/blog/WindowsLiveWriter/Therowvaluesupdatedordeletedeitherdonot_B59F/image_thumb_1.png" width="277" height="133" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;Notice the duplicate row (row 1 and row 3)&lt;/p&gt;  &lt;p&gt;So the user in this case would select the first row and hit the delete button&lt;/p&gt;  &lt;p&gt;&lt;a href="http://blog.crowe.co.nz/images/blog_crowe_co_nz/blog/WindowsLiveWriter/Therowvaluesupdatedordeletedeitherdonot_B59F/image_6.png"&gt;&lt;img style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="image" border="0" alt="image" src="http://blog.crowe.co.nz/images/blog_crowe_co_nz/blog/WindowsLiveWriter/Therowvaluesupdatedordeletedeitherdonot_B59F/image_thumb_2.png" width="431" height="165" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;They would then see this message&lt;/p&gt;  &lt;p&gt;&lt;a href="http://blog.crowe.co.nz/images/blog_crowe_co_nz/blog/WindowsLiveWriter/Therowvaluesupdatedordeletedeitherdonot_B59F/image_8.png"&gt;&lt;img style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="image" border="0" alt="image" src="http://blog.crowe.co.nz/images/blog_crowe_co_nz/blog/WindowsLiveWriter/Therowvaluesupdatedordeletedeitherdonot_B59F/image_thumb_3.png" width="434" height="230" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;So how do we get rid of the duplicate row?&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;Two options&lt;/strong&gt;&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;Option #1&lt;/strong&gt;&lt;/p&gt;  &lt;p&gt;Add a new column which contains unique values&lt;/p&gt;  &lt;p&gt;We could run the following code to add the new column and populate the new column with unique values&lt;/p&gt;  &lt;blockquote&gt;   &lt;p&gt;&lt;strong&gt;ALTER TABLE Table1       &lt;br /&gt;&lt;/strong&gt;&lt;strong&gt;ADD TempID int IDENTITY(1, 1)&lt;/strong&gt;&lt;/p&gt; &lt;/blockquote&gt;  &lt;p&gt;After issuing this command we will have something like this.&lt;/p&gt;  &lt;p&gt;&lt;a href="http://blog.crowe.co.nz/images/blog_crowe_co_nz/blog/WindowsLiveWriter/Therowvaluesupdatedordeletedeitherdonot_B59F/image_10.png"&gt;&lt;img style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="image" border="0" alt="image" src="http://blog.crowe.co.nz/images/blog_crowe_co_nz/blog/WindowsLiveWriter/Therowvaluesupdatedordeletedeitherdonot_B59F/image_thumb_4.png" width="444" height="129" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;The user can now select their row and hit delete because SQL Server can uniquely identify this row.&lt;/p&gt;  &lt;p&gt;You could then remove the new column&lt;/p&gt;  &lt;blockquote&gt;   &lt;p&gt;&lt;strong&gt;ALTER TABLE Table1       &lt;br /&gt;drop COLUMN TempID &lt;/strong&gt;&lt;/p&gt; &lt;/blockquote&gt;  &lt;p&gt;But this adds a new column to the table which is not really the best option so on to option #2&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;Option #2&lt;/strong&gt;&lt;/p&gt;  &lt;p&gt;We can simply issue a simple delete command taking advantage of the &lt;strong&gt;Set RowCount &lt;/strong&gt;command.&lt;/p&gt;  &lt;blockquote&gt;   &lt;p&gt;&lt;strong&gt;SET ROWCOUNT 1&lt;/strong&gt;&lt;/p&gt;   &lt;strong&gt;     &lt;p&gt;       &lt;br /&gt;&lt;/p&gt;     &lt;strong&gt;DELETE FROM Table1       &lt;br /&gt;&lt;/strong&gt;&lt;strong&gt;WHERE id= 1&lt;/strong&gt;&lt;/strong&gt;&lt;/blockquote&gt;  &lt;p&gt;What this does is limit the delete command to one record. Since the data is duplicated you do not care which row is deleted as long as only one of the rows is deleted. No adding and removing columns.&lt;/p&gt;&lt;img src="http://blog.crowe.co.nz/blog/aggbug/929.aspx" width="1" height="1" /&gt;</description>
            <dc:creator>Chris Crowe</dc:creator>
            <guid>http://blog.crowe.co.nz/blog/archive/2010/08/30/The-row-values-updated-or-deleted-either-do-not-make.aspx</guid>
            <pubDate>Mon, 30 Aug 2010 06:55:09 GMT</pubDate>
            <comments>http://blog.crowe.co.nz/blog/archive/2010/08/30/The-row-values-updated-or-deleted-either-do-not-make.aspx#feedback</comments>
            <slash:comments>82</slash:comments>
            <wfw:commentRss>http://blog.crowe.co.nz/blog/comments/commentRss/929.aspx</wfw:commentRss>
        </item>
        <item>
            <title>WebMatrix - a complete Web development stack that integrates a Web server, Database and more</title>
            <link>http://blog.crowe.co.nz/blog/archive/2010/07/06/WebMatrix---a-complete-Web-development-stack-that-integrates-a.aspx</link>
            <description>&lt;p&gt;WebMatrix includes a complete Web development stack that integrates a Web server (IIS Developer Express), database (Microsoft SQL Server Compact 4.0), programming model (ASP.NET Web pages with Razor syntax), and a tool (WebMatrix Beta) into a seamless experience.  You can use WebMatrix to streamline the way you create an ASP.NET Web site from templates, or by starting a new Web site by using the world’s most popular free and open source (ASP.NET or PHP) apps like DotNetNuke, Umbraco, WordPress, or Joomla!. With WebMatrix you can code your Web sites, customize them, optimize them for good search engine ranking, test them, and deploy them to an Internet hosting company, all through the tool.&lt;/p&gt;  &lt;p&gt;Learn more about WebMatrix through:&lt;/p&gt;  &lt;ul&gt;   &lt;li&gt;&lt;a href="http://go.microsoft.com/fwlink/?LinkID=195076&amp;amp;clcid=0x409"&gt;What is WebMatrix&lt;/a&gt;?  &lt;/li&gt;    &lt;li&gt;Investigate the top &lt;a href="http://go.microsoft.com/fwlink/?LinkID=195935&amp;amp;clcid=0x409"&gt;10 features&lt;/a&gt; of WebMatrix.&lt;/li&gt;    &lt;li&gt;&lt;a href="http://go.microsoft.com/fwlink/?LinkID=195938&amp;amp;clcid=0x409"&gt;Download WebMatrix Beta&lt;/a&gt;.&lt;/li&gt;    &lt;li&gt;More about &lt;a href="http://go.microsoft.com/fwlink/?LinkID=195075&amp;amp;clcid=0x409"&gt;IIS Developer Express&lt;/a&gt;. &lt;/li&gt;    &lt;li&gt;More about &lt;a href="http://go.microsoft.com/fwlink/?LinkID=195939&amp;amp;clcid=0x409"&gt;Microsoft SQL Server Compact 4.0&lt;/a&gt;.&lt;/li&gt; &lt;/ul&gt;  &lt;p&gt;For additional resources, visit:&lt;/p&gt;  &lt;ul&gt;   &lt;li&gt;&lt;a href="http://go.microsoft.com/fwlink/?LinkID=196364&amp;amp;clcid=0x409"&gt;Learn more&lt;/a&gt; about WebMatrix Beta. More resources, links to forums and feedback channels.&lt;/li&gt;    &lt;li&gt;Visit the forums on the &lt;a href="http://go.microsoft.com/fwlink/?LinkID=195074&amp;amp;clcid=0x409"&gt;IIS Web site&lt;/a&gt; or the &lt;a href="http://go.microsoft.com/fwlink/?LinkID=193026&amp;amp;clcid=0x409"&gt;ASP.NET Web site&lt;/a&gt;. &lt;/li&gt;    &lt;li&gt;&lt;a href="http://go.microsoft.com/fwlink/?LinkID=195940&amp;amp;clcid=0x409"&gt;File a bug or suggestion&lt;/a&gt; on WebMatrix Beta.&lt;/li&gt;    &lt;li&gt;Learn to program the Web using &lt;a href="http://go.microsoft.com/fwlink/?LinkID=195072&amp;amp;clcid=0x409"&gt;ASP.NET Web pages with Razor syntax&lt;/a&gt;.&lt;/li&gt;    &lt;li&gt;&lt;a href="http://go.microsoft.com/fwlink/?LinkID=195073&amp;amp;clcid=0x409"&gt;Download applications with WebMatrix&lt;/a&gt; and the Web Application Gallery.&lt;/li&gt;    &lt;li&gt;Review the &lt;a href="http://go.microsoft.com/fwlink/?LinkID=196179&amp;amp;clcid=0x409"&gt;FAQs&lt;/a&gt; for Open Source and Free Web applications.&lt;/li&gt; &lt;/ul&gt;&lt;img src="http://blog.crowe.co.nz/blog/aggbug/928.aspx" width="1" height="1" /&gt;</description>
            <dc:creator>Chris Crowe</dc:creator>
            <guid>http://blog.crowe.co.nz/blog/archive/2010/07/06/WebMatrix---a-complete-Web-development-stack-that-integrates-a.aspx</guid>
            <pubDate>Tue, 06 Jul 2010 01:49:26 GMT</pubDate>
            <comments>http://blog.crowe.co.nz/blog/archive/2010/07/06/WebMatrix---a-complete-Web-development-stack-that-integrates-a.aspx#feedback</comments>
            <slash:comments>57</slash:comments>
            <wfw:commentRss>http://blog.crowe.co.nz/blog/comments/commentRss/928.aspx</wfw:commentRss>
        </item>
        <item>
            <title>Looking for a way to find text in your SQL Database objects, then try the free Re-Gate SQL Search</title>
            <link>http://blog.crowe.co.nz/blog/archive/2010/06/27/Looking-for-a-way-to-find-text-in-your-SQL.aspx</link>
            <description>&lt;p&gt;To start I should mention that you can not search the actual data in your tables for text, but you can search your SQL Objects – Tables, Views, Stored Procedures, Constraints, Triggers and Functions for text.&lt;/p&gt;  &lt;p&gt;Often you want to find all references to a particular piece of text which could be the name of a table or column or just something that you have in a stored procedure.&lt;/p&gt;  &lt;p&gt;The free tool from Red-Gate software fits the bill well, supporting SQL 2005 and above (including the express editions of Management Studio – See below for notes on SQL Express 2005)&lt;/p&gt;  &lt;p&gt;There is some advertising links to their other products included in the tool, but they are well worth a look at if you have never used them before – Red-Gate products are great.&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;Downloading the tool&lt;/strong&gt;&lt;/p&gt;  &lt;p&gt;To download the tool simply go to &lt;a title="http://www.red-gate.com/products/sql_search/" href="http://www.red-gate.com/products/sql_search/"&gt;http://www.red-gate.com/products/sql_search/&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;&lt;/strong&gt;&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;Installation     &lt;br /&gt;&lt;/strong&gt;After you install SQL Search you get a new toolbar with a single button &lt;a href="http://blog.crowe.co.nz/images/blog_crowe_co_nz/blog/WindowsLiveWriter/LookingforawaytofindtextinyourSQLDatabas_CD32/image_2.png"&gt;&lt;img style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="image" border="0" alt="image" src="http://blog.crowe.co.nz/images/blog_crowe_co_nz/blog/WindowsLiveWriter/LookingforawaytofindtextinyourSQLDatabas_CD32/image_thumb.png" width="111" height="33" /&gt;&lt;/a&gt;  in SQL Server Management Studio. Clicking this button opens the UI which add a new tab to the current set of open tabs and will select the current database as the database to be searched (you can change this from the drop down). &lt;/p&gt;  &lt;p&gt;Note: You can only search a single database at a time.&lt;/p&gt;  &lt;p&gt;&lt;a href="http://blog.crowe.co.nz/images/blog_crowe_co_nz/blog/WindowsLiveWriter/LookingforawaytofindtextinyourSQLDatabas_CD32/image_4.png"&gt;&lt;img style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="image" border="0" alt="image" src="http://blog.crowe.co.nz/images/blog_crowe_co_nz/blog/WindowsLiveWriter/LookingforawaytofindtextinyourSQLDatabas_CD32/image_thumb_1.png" width="800" height="68" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;The search is activated by simply typing into the search field and your results are immediately displayed in a grid (no need to hit enter). &lt;/p&gt;  &lt;p&gt;You can limit the search to different types of objects such as tables or views if needed.&lt;/p&gt;  &lt;p&gt;Clicking on any of the search results will display the full text of the object where it was found with any matching text highlighted.&lt;/p&gt;  &lt;p&gt;&lt;a href="http://blog.crowe.co.nz/images/blog_crowe_co_nz/blog/WindowsLiveWriter/LookingforawaytofindtextinyourSQLDatabas_CD32/image_6.png"&gt;&lt;img style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="image" border="0" alt="image" src="http://blog.crowe.co.nz/images/blog_crowe_co_nz/blog/WindowsLiveWriter/LookingforawaytofindtextinyourSQLDatabas_CD32/image_thumb_2.png" width="800" height="367" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;&lt;strong&gt;SQL 2005 Management Studio Express&lt;/strong&gt;&lt;/p&gt;  &lt;p&gt;This statement is included on the requirements page for SQL Search at &lt;a title="http://www.red-gate.com/products/sql_search/requirements.htm" href="http://www.red-gate.com/products/sql_search/requirements.htm"&gt;http://www.red-gate.com/products/sql_search/requirements.htm&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;* To use SQL Search with SSMS 2005 Express Edition, &lt;em&gt;extensibility.dll&lt;/em&gt; must be installed.&lt;/strong&gt;&lt;/p&gt;  &lt;p&gt;But then they give you no indication of what that means or where you get it from. &lt;/p&gt;  &lt;p&gt;You can download the &lt;b&gt;extensibility&lt;/b&gt;.&lt;b&gt;dll&lt;/b&gt; by installing the following tool:    &lt;br /&gt;&lt;a href="ftp://ftp.red-gate.com/development/sqlprompt/extensibilitymsm.msi"&gt;ftp://ftp.red-gate.com/development/sqlprompt/extensibilitymsm.msi&lt;/a&gt;&lt;/p&gt;&lt;img src="http://blog.crowe.co.nz/blog/aggbug/927.aspx" width="1" height="1" /&gt;</description>
            <dc:creator>Chris Crowe</dc:creator>
            <guid>http://blog.crowe.co.nz/blog/archive/2010/06/27/Looking-for-a-way-to-find-text-in-your-SQL.aspx</guid>
            <pubDate>Sun, 27 Jun 2010 08:35:47 GMT</pubDate>
            <comments>http://blog.crowe.co.nz/blog/archive/2010/06/27/Looking-for-a-way-to-find-text-in-your-SQL.aspx#feedback</comments>
            <slash:comments>58</slash:comments>
            <wfw:commentRss>http://blog.crowe.co.nz/blog/comments/commentRss/927.aspx</wfw:commentRss>
        </item>
        <item>
            <title>SQL Server : TSQL Return start/end price and start/end date time by product name</title>
            <link>http://blog.crowe.co.nz/blog/archive/2010/06/22/SQL-Server--TSQL-Return-startend-price-and-startend-date.aspx</link>
            <description>&lt;p&gt;As part of trying to monitor my power usage and to know when my power prices change I download the power prices online from my power provider every 15 minutes and store this in a database.&lt;/p&gt;  &lt;p&gt;I have been doing this for more than 4 months now and wanted to produce some data showing how the prices have changed over time.&lt;/p&gt;  &lt;p&gt;I wanted to produce a report of all of the price movements per product over time.&lt;/p&gt;  &lt;p&gt;&lt;a href="http://blog.crowe.co.nz/images/blog_crowe_co_nz/blog/WindowsLiveWriter/SQLServerCTEtoreturn_BA46/image_8.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" src="http://blog.crowe.co.nz/images/blog_crowe_co_nz/blog/WindowsLiveWriter/SQLServerCTEtoreturn_BA46/image_thumb_3.png" width="535" height="212" /&gt;&lt;/a&gt;     &lt;br /&gt;&lt;/p&gt;  &lt;h3&gt;The Database&lt;/h3&gt;  &lt;p&gt;&lt;strong&gt;I have two SQL Server tables described below that contain the data: &lt;/strong&gt;&lt;/p&gt;  &lt;pre class="csharpcode"&gt;&lt;span class="kwrd"&gt;CREATE&lt;/span&gt; &lt;span class="kwrd"&gt;TABLE&lt;/span&gt; [dbo].[PowerUpdate](
    [id] [&lt;span class="kwrd"&gt;int&lt;/span&gt;] &lt;span class="kwrd"&gt;IDENTITY&lt;/span&gt;(1,1) &lt;span class="kwrd"&gt;NOT&lt;/span&gt; &lt;span class="kwrd"&gt;NULL&lt;/span&gt;,
    [DateTime] [datetime] &lt;span class="kwrd"&gt;NOT&lt;/span&gt; &lt;span class="kwrd"&gt;NULL&lt;/span&gt;,
    [Enabled] [&lt;span class="kwrd"&gt;bit&lt;/span&gt;] &lt;span class="kwrd"&gt;NOT&lt;/span&gt; &lt;span class="kwrd"&gt;NULL&lt;/span&gt;
)&lt;/pre&gt;

&lt;pre class="csharpcode"&gt;&lt;span class="kwrd"&gt;CREATE&lt;/span&gt; &lt;span class="kwrd"&gt;TABLE&lt;/span&gt; [dbo].[PowerItem](
    [id] [&lt;span class="kwrd"&gt;int&lt;/span&gt;] &lt;span class="kwrd"&gt;IDENTITY&lt;/span&gt;(1,1) &lt;span class="kwrd"&gt;NOT&lt;/span&gt; &lt;span class="kwrd"&gt;NULL&lt;/span&gt;,
    [PowerUpdateID] [&lt;span class="kwrd"&gt;int&lt;/span&gt;] &lt;span class="kwrd"&gt;NOT&lt;/span&gt; &lt;span class="kwrd"&gt;NULL&lt;/span&gt;,
    [Name] [nvarchar](128) &lt;span class="kwrd"&gt;NOT&lt;/span&gt; &lt;span class="kwrd"&gt;NULL&lt;/span&gt;,
    [Price] [&lt;span class="kwrd"&gt;decimal&lt;/span&gt;](9, 4) &lt;span class="kwrd"&gt;NOT&lt;/span&gt; &lt;span class="kwrd"&gt;NULL&lt;/span&gt;,
    [Type] [nvarchar](128) &lt;span class="kwrd"&gt;NOT&lt;/span&gt; &lt;span class="kwrd"&gt;NULL&lt;/span&gt;,
    [Description] [ntext] &lt;span class="kwrd"&gt;NULL&lt;/span&gt;,
)&lt;/pre&gt;

&lt;p&gt;&lt;strong&gt;I also have one view that just joins the tables back together for reporting purposes.&lt;/strong&gt;&lt;/p&gt;

&lt;pre class="csharpcode"&gt;&lt;span class="kwrd"&gt;CREATE&lt;/span&gt; &lt;span class="kwrd"&gt;VIEW&lt;/span&gt; [dbo].[vPowerData]
&lt;span class="kwrd"&gt;as&lt;/span&gt;
&lt;span class="kwrd"&gt;SELECT&lt;/span&gt;     PowerItem_1.id, PowerItem_1.Name, PowerItem_1.Price, PowerUpdate_1.DateTime
&lt;span class="kwrd"&gt;FROM&lt;/span&gt;       PowerItem &lt;span class="kwrd"&gt;AS&lt;/span&gt; PowerItem_1 &lt;br /&gt;&lt;span class="kwrd"&gt;INNER&lt;/span&gt; &lt;span class="kwrd"&gt;JOIN &lt;/span&gt;PowerUpdate &lt;span class="kwrd"&gt;AS&lt;/span&gt; PowerUpdate_1 &lt;span class="kwrd"&gt;ON&lt;/span&gt; PowerItem_1.PowerUpdateID = PowerUpdate_1.id&lt;/pre&gt;
&lt;style type="text/css"&gt;&lt;![CDATA[










.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }]]&gt;&lt;/style&gt;

&lt;p&gt;&lt;/p&gt;

&lt;hr /&gt;

&lt;p&gt;&lt;/p&gt;

&lt;h3&gt;Some sample data&lt;/h3&gt;

&lt;p&gt;So here is some examples of the data that I have in the database. &lt;/p&gt;

&lt;table border="0" cellspacing="0" cellpadding="2"&gt;&lt;tbody&gt;
    &lt;tr&gt;
      &lt;td valign="top"&gt;&lt;strong&gt;select top 10 * from powerupdate&lt;/strong&gt;&lt;/td&gt;

      &lt;td valign="top"&gt;&lt;strong&gt;select top 10 * from poweritem&lt;/strong&gt;&lt;/td&gt;
    &lt;/tr&gt;

    &lt;tr&gt;
      &lt;td valign="top"&gt;&lt;a href="http://blog.crowe.co.nz/images/blog_crowe_co_nz/blog/WindowsLiveWriter/SQLServerCTEtoreturn_BA46/image_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="image" border="0" alt="image" src="http://blog.crowe.co.nz/images/blog_crowe_co_nz/blog/WindowsLiveWriter/SQLServerCTEtoreturn_BA46/image_thumb.png" width="252" height="212" /&gt;&lt;/a&gt;&lt;/td&gt;

      &lt;td valign="top"&gt;&lt;a href="http://blog.crowe.co.nz/images/blog_crowe_co_nz/blog/WindowsLiveWriter/SQLServerCTEtoreturn_BA46/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" src="http://blog.crowe.co.nz/images/blog_crowe_co_nz/blog/WindowsLiveWriter/SQLServerCTEtoreturn_BA46/image_thumb_2.png" width="673" height="211" /&gt;&lt;/a&gt;&lt;/td&gt;
    &lt;/tr&gt;
  &lt;/tbody&gt;&lt;/table&gt;

&lt;p&gt;&lt;strong&gt;PowerUpdate&lt;/strong&gt; contains records with an ID and a Date and Time which identifies when the update occurred.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;PowerItem&lt;/strong&gt; contains the actual power products that were available for the particular update date &amp;amp; time and their current price.&lt;/p&gt;

&lt;p&gt; &lt;/p&gt;

&lt;h3&gt;What I want in my report&lt;/h3&gt;

&lt;p&gt;What I would like to see is for every product, the date and time when the price was first seen, and the last date and time that the price was seen and the actual prices.&lt;/p&gt;

&lt;p&gt;To make it more complex a product’s price could return to the same value as a previous date and time and I would like the last price to display null for the next price and next price datetime fields.&lt;/p&gt;

&lt;p&gt;Here is an example of the required output 
  &lt;br /&gt;&lt;a href="http://blog.crowe.co.nz/images/blog_crowe_co_nz/blog/WindowsLiveWriter/SQLServerCTEtoreturn_BA46/image_8.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" src="http://blog.crowe.co.nz/images/blog_crowe_co_nz/blog/WindowsLiveWriter/SQLServerCTEtoreturn_BA46/image_thumb_3.png" width="535" height="212" /&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt; &lt;/p&gt;

&lt;h3&gt;The final solution&lt;/h3&gt;

&lt;p&gt;Now I had problems trying to get my head around my report requirement. I spent some time trying to come up with a solution but failed – I knew that it could be done using a SET based solution, which is what I wanted, but I could not do it myself.&lt;/p&gt;

&lt;p&gt;I posted my question to the guru’s at &lt;a href="http://www.sqlservercentral.com"&gt;www.sqlservercentral.com&lt;/a&gt; – the original post is here &lt;a title="http://www.sqlservercentral.com/Forums/Topic930464-338-1.aspx" href="http://www.sqlservercentral.com/Forums/Topic930464-338-1.aspx"&gt;http://www.sqlservercentral.com/Forums/Topic930464-338-1.aspx&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;I received some good replies from people on the forum and really appreciate the work all the people put into this, to help me!&lt;/p&gt;

&lt;p&gt;I liked the solution provided by a member called “&lt;a href="http://www.sqlservercentral.com/Forums/UserInfo106082.aspx"&gt;Mark-101232&lt;/a&gt;” &lt;/p&gt;

&lt;p&gt;Below is his solution to the problem which did exactly what I needed and was very fast compared to some solutions given.&lt;/p&gt;

&lt;hr /&gt;

&lt;p&gt;&lt;/p&gt;

&lt;pre class="csharpcode"&gt;&lt;span class="kwrd"&gt;WITH&lt;/span&gt; CTE1 &lt;span class="kwrd"&gt;AS&lt;/span&gt; (
&lt;span class="kwrd"&gt;SELECT&lt;/span&gt; Name ,Price ,DateTime,
       ROW_NUMBER() &lt;span class="kwrd"&gt;OVER&lt;/span&gt;(PARTITION &lt;span class="kwrd"&gt;BY&lt;/span&gt; Name &lt;span class="kwrd"&gt;ORDER&lt;/span&gt; &lt;span class="kwrd"&gt;BY&lt;/span&gt; DATETime) &lt;span class="kwrd"&gt;AS&lt;/span&gt; rn1,
       ROW_NUMBER() &lt;span class="kwrd"&gt;OVER&lt;/span&gt;(PARTITION &lt;span class="kwrd"&gt;BY&lt;/span&gt; Name,Price &lt;span class="kwrd"&gt;ORDER&lt;/span&gt; &lt;span class="kwrd"&gt;BY&lt;/span&gt; DATETime) &lt;span class="kwrd"&gt;AS&lt;/span&gt; rn2
&lt;span class="kwrd"&gt;FROM&lt;/span&gt; dbo.vPowerData),
CTE2 &lt;span class="kwrd"&gt;AS&lt;/span&gt; (
&lt;span class="kwrd"&gt;SELECT&lt;/span&gt; Name,Price &lt;span class="kwrd"&gt;AS&lt;/span&gt; [&lt;span class="kwrd"&gt;Min&lt;/span&gt; Price],&lt;span class="kwrd"&gt;MIN&lt;/span&gt;(DateTime) &lt;span class="kwrd"&gt;AS&lt;/span&gt; [&lt;span class="kwrd"&gt;Min&lt;/span&gt; DateTime],&lt;span class="kwrd"&gt;MAX&lt;/span&gt;(rn1) &lt;span class="kwrd"&gt;AS&lt;/span&gt; maxRN
&lt;span class="kwrd"&gt;FROM&lt;/span&gt; CTE1
&lt;span class="kwrd"&gt;GROUP&lt;/span&gt; &lt;span class="kwrd"&gt;BY&lt;/span&gt; Name,Price,rn2-rn1)
&lt;span class="kwrd"&gt;SELECT&lt;/span&gt; a.Name,a.[&lt;span class="kwrd"&gt;Min&lt;/span&gt; Price],a.[&lt;span class="kwrd"&gt;Min&lt;/span&gt; DateTime],
       b.Price &lt;span class="kwrd"&gt;AS&lt;/span&gt; [NextPrice],
       b.DateTime &lt;span class="kwrd"&gt;AS&lt;/span&gt; [&lt;span class="kwrd"&gt;Next&lt;/span&gt; Price DateTime]
&lt;span class="kwrd"&gt;FROM&lt;/span&gt; CTE2 a
&lt;span class="kwrd"&gt;LEFT&lt;/span&gt; &lt;span class="kwrd"&gt;OUTER&lt;/span&gt; &lt;span class="kwrd"&gt;JOIN&lt;/span&gt; CTE1 b &lt;span class="kwrd"&gt;ON&lt;/span&gt; b.Name=a.Name &lt;span class="kwrd"&gt;AND&lt;/span&gt; b.rn1=a.maxRN+1 &lt;span class="kwrd"&gt;AND&lt;/span&gt; b.DateTime&amp;gt;a.[&lt;span class="kwrd"&gt;Min&lt;/span&gt; DateTime]
&lt;span class="kwrd"&gt;ORDER&lt;/span&gt; &lt;span class="kwrd"&gt;BY&lt;/span&gt; a.Name,a.[&lt;span class="kwrd"&gt;Min&lt;/span&gt; DateTime];

&lt;hr /&gt;&lt;/pre&gt;

&lt;p&gt;&lt;/p&gt;

&lt;p&gt;Now although I have a solution I really need to understand the logic here so I decided to write this blog post to try to strip down this TSQL code so I can actually understand what is going on and in the process this may help someone else as well.&lt;/p&gt;

&lt;p&gt;&lt;/p&gt;

&lt;hr /&gt;

&lt;p&gt;&lt;/p&gt;

&lt;h3&gt;The first step is to split the query down into its parts.&lt;/h3&gt;

&lt;h3&gt;&lt;strong&gt;Part 1&lt;/strong&gt;&lt;/h3&gt;

&lt;pre class="csharpcode"&gt;&lt;span class="kwrd"&gt;SELECT&lt;/span&gt; Name ,Price ,DateTime,
       ROW_NUMBER() &lt;span class="kwrd"&gt;OVER&lt;/span&gt;(PARTITION &lt;span class="kwrd"&gt;BY&lt;/span&gt; Name &lt;span class="kwrd"&gt;ORDER&lt;/span&gt; &lt;span class="kwrd"&gt;BY&lt;/span&gt; DATETime) &lt;span class="kwrd"&gt;AS&lt;/span&gt; rn1,
       ROW_NUMBER() &lt;span class="kwrd"&gt;OVER&lt;/span&gt;(PARTITION &lt;span class="kwrd"&gt;BY&lt;/span&gt; Name,Price &lt;span class="kwrd"&gt;ORDER&lt;/span&gt; &lt;span class="kwrd"&gt;BY&lt;/span&gt; DATETime) &lt;span class="kwrd"&gt;AS&lt;/span&gt; rn2
&lt;span class="kwrd"&gt;FROM&lt;/span&gt; dbo.vPowerData&lt;/pre&gt;

&lt;pre class="csharpcode"&gt; &lt;/pre&gt;

&lt;p&gt;What this is TSQL is doing is return the name, price and date time and also two row numbers. &lt;/p&gt;

&lt;p&gt;For more details on row_number() see &lt;a title="http://msdn.microsoft.com/en-us/library/ms186734.aspx" href="http://msdn.microsoft.com/en-us/library/ms186734.aspx"&gt;http://msdn.microsoft.com/en-us/library/ms186734.aspx&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The first row_number() function returns the a row number (resetting it to 1 when the name changes) and ordering it by the date time&lt;/p&gt;

&lt;p&gt;The second row_number() function returns the a row number (resetting it to 1 when the name and price changes) and ordering it by the date time&lt;/p&gt;

&lt;p&gt;The easiest way to look at this is to look at a subset of data and show you what gets returned.&lt;/p&gt;

&lt;p&gt;Assume our PowerItem table only contains the following records&lt;/p&gt;

&lt;p&gt;&lt;a href="http://blog.crowe.co.nz/images/blog_crowe_co_nz/blog/WindowsLiveWriter/SQLServerCTEtoreturn_BA46/image_18.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" src="http://blog.crowe.co.nz/images/blog_crowe_co_nz/blog/WindowsLiveWriter/SQLServerCTEtoreturn_BA46/image_thumb_8.png" width="315" height="251" /&gt;&lt;/a&gt; &lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Note&lt;/strong&gt;: There are 3 different products listed, but only the “$49.95 Value Pack” has had the price changing as follows:&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;0.1693 &lt;/li&gt;

  &lt;li&gt;0.1698 &lt;/li&gt;

  &lt;li&gt;0.1691 &lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The TSQL code in &lt;strong&gt;Part 1&lt;/strong&gt; will return the following result set &lt;/p&gt;

&lt;p&gt;&lt;a href="http://blog.crowe.co.nz/images/blog_crowe_co_nz/blog/WindowsLiveWriter/SQLServerCTEtoreturn_BA46/image_20.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" src="http://blog.crowe.co.nz/images/blog_crowe_co_nz/blog/WindowsLiveWriter/SQLServerCTEtoreturn_BA46/image_thumb_9.png" width="388" height="249" /&gt;&lt;/a&gt; &lt;/p&gt;

&lt;h3&gt;Part 2&lt;/h3&gt;

&lt;pre class="csharpcode"&gt;&lt;span class="kwrd"&gt;SELECT&lt;/span&gt; Name,Price &lt;span class="kwrd"&gt;AS&lt;/span&gt; [&lt;span class="kwrd"&gt;Min&lt;/span&gt; Price],&lt;span class="kwrd"&gt;MIN&lt;/span&gt;(DateTime) &lt;span class="kwrd"&gt;AS&lt;/span&gt; [&lt;span class="kwrd"&gt;Min&lt;/span&gt; DateTime],&lt;span class="kwrd"&gt;MAX&lt;/span&gt;(rn1) &lt;span class="kwrd"&gt;AS&lt;/span&gt; maxRN
&lt;span class="kwrd"&gt;FROM&lt;/span&gt; CTE1
&lt;span class="kwrd"&gt;GROUP&lt;/span&gt; &lt;span class="kwrd"&gt;BY&lt;/span&gt; Name,Price,rn2-rn1&lt;/pre&gt;

&lt;p&gt;Note: In this case treat CTE1 as the final result set that is visible in Part 1 above&lt;/p&gt;

&lt;p&gt;The TSQL code in &lt;strong&gt;Part 2&lt;/strong&gt; returns the following result set&lt;/p&gt;

&lt;p&gt;&lt;a href="http://blog.crowe.co.nz/images/blog_crowe_co_nz/blog/WindowsLiveWriter/SQLServerCTEtoreturn_BA46/image_24.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" src="http://blog.crowe.co.nz/images/blog_crowe_co_nz/blog/WindowsLiveWriter/SQLServerCTEtoreturn_BA46/image_thumb_11.png" width="390" height="115" /&gt;&lt;/a&gt; &lt;/p&gt;

&lt;h3&gt;Part 3&lt;/h3&gt;

&lt;pre class="csharpcode"&gt;&lt;span class="kwrd"&gt;SELECT&lt;/span&gt; a.Name,a.[&lt;span class="kwrd"&gt;Min&lt;/span&gt; Price],a.[&lt;span class="kwrd"&gt;Min&lt;/span&gt; DateTime],
       b.Price &lt;span class="kwrd"&gt;AS&lt;/span&gt; [NextPrice],
       b.DateTime &lt;span class="kwrd"&gt;AS&lt;/span&gt; [&lt;span class="kwrd"&gt;Next&lt;/span&gt; Price DateTime]
&lt;span class="kwrd"&gt;FROM&lt;/span&gt; CTE2 a
&lt;span class="kwrd"&gt;LEFT&lt;/span&gt; &lt;span class="kwrd"&gt;OUTER&lt;/span&gt; &lt;span class="kwrd"&gt;JOIN&lt;/span&gt; CTE1 b &lt;span class="kwrd"&gt;ON&lt;/span&gt; b.Name=a.Name &lt;span class="kwrd"&gt;AND&lt;/span&gt; b.rn1=a.maxRN+1 &lt;span class="kwrd"&gt;AND&lt;/span&gt; b.DateTime&amp;gt;a.[&lt;span class="kwrd"&gt;Min&lt;/span&gt; DateTime]
&lt;span class="kwrd"&gt;ORDER&lt;/span&gt; &lt;span class="kwrd"&gt;BY&lt;/span&gt; a.Name,a.[&lt;span class="kwrd"&gt;Min&lt;/span&gt; DateTime];&lt;/pre&gt;

&lt;p&gt;Part 3 is really just a simple Left Outer Join sorted by name and the Minimum Date Time, the reason for the left outer join is that we want the final price and date.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Hint&lt;/strong&gt;: I often try to think as CTE (Common Table Expressions) as a physical table and you can therefore logically join it easier (well it works for me - sometimes)&lt;/p&gt;

&lt;p&gt; &lt;/p&gt;

&lt;table border="0" cellspacing="0" cellpadding="2"&gt;&lt;tbody&gt;
    &lt;tr&gt;
      &lt;td valign="top"&gt;&lt;strong&gt;CTE 1 AS B&lt;/strong&gt;&lt;/td&gt;

      &lt;td valign="top"&gt;&lt;strong&gt;CTE 2 AS A&lt;/strong&gt;&lt;/td&gt;
    &lt;/tr&gt;

    &lt;tr&gt;
      &lt;td valign="top"&gt;&lt;a href="http://blog.crowe.co.nz/images/blog_crowe_co_nz/blog/WindowsLiveWriter/SQLServerCTEtoreturn_BA46/image_22.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" src="http://blog.crowe.co.nz/images/blog_crowe_co_nz/blog/WindowsLiveWriter/SQLServerCTEtoreturn_BA46/image_thumb_10.png" width="388" height="249" /&gt;&lt;/a&gt; &lt;/td&gt;

      &lt;td valign="top"&gt;&lt;a href="http://blog.crowe.co.nz/images/blog_crowe_co_nz/blog/WindowsLiveWriter/SQLServerCTEtoreturn_BA46/image_26.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" src="http://blog.crowe.co.nz/images/blog_crowe_co_nz/blog/WindowsLiveWriter/SQLServerCTEtoreturn_BA46/image_thumb_12.png" width="390" height="115" /&gt;&lt;/a&gt; &lt;/td&gt;
    &lt;/tr&gt;
  &lt;/tbody&gt;&lt;/table&gt;

&lt;p&gt;&lt;/p&gt;

&lt;p&gt;&lt;/p&gt;

&lt;p&gt;&lt;/p&gt;

&lt;p&gt;So in this case we have the following going on (for the product name ‘$49.95 Value Pack’)&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;Row 1 
    &lt;ul&gt;
      &lt;li&gt;Row 1 does not join to CTE2 since b.rn1 (in this case 4) = a.maxRN+1 (in this case 5) does not exist &lt;/li&gt;
    &lt;/ul&gt;
  &lt;/li&gt;

  &lt;li&gt;Row 2 
    &lt;ul&gt;
      &lt;li&gt;Row 2 does not join to CTE2 since b.rn1 (in this case 1) = a.maxRN+1 (in this case 2) does not exist &lt;/li&gt;
    &lt;/ul&gt;
  &lt;/li&gt;

  &lt;li&gt;Row 3 
    &lt;ul&gt;
      &lt;li&gt;Row 3 does join CTE2 since b.rn1 (in this case 2) = a.maxRN+1 (in this case 3) does exist &lt;/li&gt;
    &lt;/ul&gt;
  &lt;/li&gt;

  &lt;li&gt;Row 4 
    &lt;ul&gt;
      &lt;li&gt;Row 4 does join CTE2 since b.rn1 (in this case 3) = a.maxRN+1 (in this case 4) does exist &lt;/li&gt;
    &lt;/ul&gt;
  &lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Note&lt;/strong&gt;: there is also other filtered here such as b.name = a.name and b.datetime &amp;gt; a.[min datetime]&lt;/p&gt;

&lt;p&gt;So for the first 4 rows this products the following output (when the order by clause is added)&lt;/p&gt;

&lt;p&gt;&lt;a href="http://blog.crowe.co.nz/images/blog_crowe_co_nz/blog/WindowsLiveWriter/SQLServerCTEtoreturn_BA46/image_28.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" src="http://blog.crowe.co.nz/images/blog_crowe_co_nz/blog/WindowsLiveWriter/SQLServerCTEtoreturn_BA46/image_thumb_13.png" width="538" height="79" /&gt;&lt;/a&gt; &lt;/p&gt;

&lt;p&gt;&lt;/p&gt;

&lt;p&gt;Now I hope I have explained what is going on because I am still trying to decipher and understand this myself.&lt;/p&gt;

&lt;p&gt;But in any case it has made it easier for me to comprehend so I am happy with that and if it helps anyone else then that is good.&lt;/p&gt;

&lt;p&gt;&lt;/p&gt;

&lt;hr /&gt;

&lt;p&gt;&lt;/p&gt;

&lt;p&gt;Additional resources to create database and populate with data&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;&lt;a href="http://blog.crowe.co.nz/attachments/CreatePowerShopDatabaseAndTable.txt"&gt;Script to create database and tables&lt;/a&gt; &lt;/li&gt;

  &lt;li&gt;&lt;a href="http://blog.crowe.co.nz/attachments/powerdata.rar"&gt;Script to add 4 months worth of data&lt;/a&gt; (1 MB download, expands to 150MB)&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Notes:&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;Additional indexes could help in the solution as well. &lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Additional comments:&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;Many thanks to those that answered or submitted a potential solution to my query on SQL Server Central – it was very much appreciated. I am in no way trying to take away from what you have done, but instead hope I am helping others in the SQL Server community by understanding the particular solution I choose to accept, and hopefully explaining it so we can all learn and be better TSQL developers. &lt;/li&gt;
&lt;/ul&gt;&lt;img src="http://blog.crowe.co.nz/blog/aggbug/926.aspx" width="1" height="1" /&gt;</description>
            <dc:creator>Chris Crowe</dc:creator>
            <guid>http://blog.crowe.co.nz/blog/archive/2010/06/22/SQL-Server--TSQL-Return-startend-price-and-startend-date.aspx</guid>
            <pubDate>Tue, 22 Jun 2010 10:14:37 GMT</pubDate>
            <comments>http://blog.crowe.co.nz/blog/archive/2010/06/22/SQL-Server--TSQL-Return-startend-price-and-startend-date.aspx#feedback</comments>
            <slash:comments>65</slash:comments>
            <wfw:commentRss>http://blog.crowe.co.nz/blog/comments/commentRss/926.aspx</wfw:commentRss>
        </item>
        <item>
            <title>An error occurred in the Microsoft .NET Framework while trying to load assembly id 65551. The server may be running out of resources, or the assembly may not be trusted with PERMISSION_SET = EXTERNAL_ACCESS or UNSAFE</title>
            <link>http://blog.crowe.co.nz/blog/archive/2010/06/04/An-error-occurred-in-the-Microsoft-.NET-Framework-while-trying.aspx</link>
            <description>&lt;h3&gt;Server Error in '/' Application.    &lt;hr size="1" width="100%" /&gt;&lt;/h3&gt;  &lt;h4&gt;&lt;i&gt;An error occurred in the Microsoft .NET Framework while trying to load assembly id 65551. The server may be running out of resources, or the assembly may not be trusted with PERMISSION_SET = EXTERNAL_ACCESS or UNSAFE. Run the query again, or check documentation to see how to solve the assembly trust issues. For more information about this error:      &lt;br /&gt;System.IO.FileLoadException: Could not load file or assembly 'sqlservertimezones, Version=1.0.0.0, Culture=neutral, PublicKeyToken=f34ea75f04c42955' or one of its dependencies. The given assembly name or codebase was invalid. (Exception from HRESULT: 0x80131047)      &lt;br /&gt;System.IO.FileLoadException:       &lt;br /&gt;  at System.Reflection.Assembly._nLoad(AssemblyName fileName, String codeBase, Evidence assemblySecurity, Assembly locationHint, StackCrawlMark&amp;amp; stackMark, Boolean throwOnFileNotFound, Boolean forIntrospection)      &lt;br /&gt;  at System.Reflection.Assembly.nLoad(AssemblyName fileName, String codeBase, Evidence assemblySecurity, Assembly locationHint, StackCrawlMark&amp;amp; stackMark, Boolean throwOnFileNotFound, Boolean forIntrospection)      &lt;br /&gt;  at System.Reflection.Assembly.InternalLoad(AssemblyName assemblyRef, Evidence assemblySecurity, StackCrawlMark&amp;amp; stackMark, Boolean forIntrospection)      &lt;br /&gt;  at System.Reflection.Assembly.InternalLoad(String assemblyString, Evidence assemblySecurity, StackCrawlMark&amp;amp; stackMark, Boolean forIntrospection)      &lt;br /&gt;  at System.Reflection.Assembly.Load(String assemblyString)      &lt;br /&gt;&lt;/i&gt;&lt;/h4&gt;  &lt;p&gt;I recently got this error after moving a database from SQL Server 2008 to SQL Server 2008 R2 – there are some articles that can help you with this error:&lt;/p&gt;  &lt;p&gt;Msg 10314, Level 16, State 11, Line 1&lt;/p&gt;  &lt;p&gt; &lt;/p&gt;  &lt;p&gt;&lt;a title="http://support.microsoft.com/kb/918040" href="http://support.microsoft.com/kb/918040"&gt;http://support.microsoft.com/kb/918040&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;&lt;a title="http://blogs.msdn.com/b/psssql/archive/2010/03/23/unable-to-load-clr-assembly-intermittently.aspx" href="http://blogs.msdn.com/b/psssql/archive/2010/03/23/unable-to-load-clr-assembly-intermittently.aspx"&gt;http://blogs.msdn.com/b/psssql/archive/2010/03/23/unable-to-load-clr-assembly-intermittently.aspx&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;&lt;a title="http://www.sqlnewsgroups.net/group/microsoft.public.sqlserver.server/topic16037.aspx" href="http://www.sqlnewsgroups.net/group/microsoft.public.sqlserver.server/topic16037.aspx"&gt;http://www.sqlnewsgroups.net/group/microsoft.public.sqlserver.server/topic16037.aspx&lt;/a&gt;&lt;/p&gt;  &lt;p&gt; &lt;/p&gt;  &lt;p&gt;In my case none of the solutions helped me and then I thought about the actual assembly. My SQL Server 2008 is running on Windows Server 2008 64Bit, but the SQL Server 2008 R2 was running on 32Bit Windows Server 2008.&lt;/p&gt;  &lt;p&gt;I had a look at the assembly compilation properties in Visual studio and noticed that it was a 64Bit DLL and not a 32bit one.&lt;/p&gt;  &lt;p&gt;I recompiled and replaced the DLL and reran my setup for the assembly and it resolved my problem.&lt;/p&gt;&lt;img src="http://blog.crowe.co.nz/blog/aggbug/924.aspx" width="1" height="1" /&gt;</description>
            <dc:creator>Chris Crowe</dc:creator>
            <guid>http://blog.crowe.co.nz/blog/archive/2010/06/04/An-error-occurred-in-the-Microsoft-.NET-Framework-while-trying.aspx</guid>
            <pubDate>Fri, 04 Jun 2010 07:28:24 GMT</pubDate>
            <comments>http://blog.crowe.co.nz/blog/archive/2010/06/04/An-error-occurred-in-the-Microsoft-.NET-Framework-while-trying.aspx#feedback</comments>
            <slash:comments>36</slash:comments>
            <wfw:commentRss>http://blog.crowe.co.nz/blog/comments/commentRss/924.aspx</wfw:commentRss>
        </item>
        <item>
            <title>Looking for some new sounds &amp;ndash; checkout this freebee</title>
            <link>http://blog.crowe.co.nz/blog/archive/2009/07/18/Looking-for-some-new-sounds-ndash-checkout-this-freebee.aspx</link>
            <description>&lt;p&gt;Click to download new music, completely free, brought to you by your music loving friends at Windows. You'll see (but not hear) some ads on your screen in addition to the album's cover art, which is how we (they) keep your new tunes from costing you a cent.&lt;/p&gt;  &lt;p&gt;Well worth a listen to checkout some new bands and artists….&lt;/p&gt;  &lt;p&gt;Listen online, download MP3 or WMA&lt;/p&gt;  &lt;p&gt;&lt;a title="http://sponsoredsongs.reverbnation.com/windows?utm_source=windows_myspace_page&amp;amp;utm_medium=button_link&amp;amp;utm_campaign=ms_windows&amp;amp;utm_content=thousand_more" href="http://sponsoredsongs.reverbnation.com/windows?utm_source=windows_myspace_page&amp;amp;utm_medium=button_link&amp;amp;utm_campaign=ms_windows&amp;amp;utm_content=thousand_more"&gt;http://sponsoredsongs.reverbnation.com/windows?utm_source=windows_myspace_page&amp;amp;utm_medium=button_link&amp;amp;utm_campaign=ms_windows&amp;amp;utm_content=thousand_more&lt;/a&gt;&lt;/p&gt;&lt;img src="http://blog.crowe.co.nz/blog/aggbug/923.aspx" width="1" height="1" /&gt;</description>
            <dc:creator>Chris Crowe</dc:creator>
            <guid>http://blog.crowe.co.nz/blog/archive/2009/07/18/Looking-for-some-new-sounds-ndash-checkout-this-freebee.aspx</guid>
            <pubDate>Fri, 17 Jul 2009 20:40:37 GMT</pubDate>
            <comments>http://blog.crowe.co.nz/blog/archive/2009/07/18/Looking-for-some-new-sounds-ndash-checkout-this-freebee.aspx#feedback</comments>
            <slash:comments>52</slash:comments>
            <wfw:commentRss>http://blog.crowe.co.nz/blog/comments/commentRss/923.aspx</wfw:commentRss>
        </item>
    </channel>
</rss>