<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="http://blogs.msdn.com/utility/FeedStylesheets/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/"><channel><title>Mark Brown's Blog</title><link>http://blogs.msdn.com/mab/default.aspx</link><description>TFS, Visual Studio, SQL Server, BizTalk, SharePoint, .Net, and more ...</description><dc:language>en-US</dc:language><generator>CommunityServer 2.1 SP1 (Build: 61025.2)</generator><item><title>Visual Studio and .Net Tutorials and Training Videos</title><link>http://blogs.msdn.com/mab/archive/2009/11/10/visual-studio-and-net-tutorials-and-training-videos.aspx</link><pubDate>Tue, 10 Nov 2009 15:41:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9920204</guid><dc:creator>mab</dc:creator><slash:comments>0</slash:comments><comments>http://blogs.msdn.com/mab/comments/9920204.aspx</comments><wfw:commentRss>http://blogs.msdn.com/mab/commentrss.aspx?PostID=9920204</wfw:commentRss><wfw:comment>http://blogs.msdn.com/mab/rsscomments.aspx?PostID=9920204</wfw:comment><description>&lt;P&gt;A friend asked about some sites to learn about Visual Studio and programming.&amp;nbsp;&amp;nbsp; There is a lot of great free resources out there.&amp;nbsp;&amp;nbsp; I created an article with a starting list to help.&amp;nbsp; Feel free to comment and suggest the "best" free sites out there.&lt;/P&gt;
&lt;P&gt;&lt;A class="" href="http://blogs.msdn.com/mab/pages/visual-studio-tutorials-and-training-videos.aspx" mce_href="http://blogs.msdn.com/mab/pages/visual-studio-tutorials-and-training-videos.aspx"&gt;Visual Studio and .Net Tutorials and Training Videos&lt;/A&gt;&lt;/P&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=9920204" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/mab/archive/tags/Visual+Studio/default.aspx">Visual Studio</category></item><item><title>Steps to add Developer Tools to Send To folder</title><link>http://blogs.msdn.com/mab/archive/2009/10/09/steps-to-add-developer-tools-to-send-to-folder.aspx</link><pubDate>Fri, 09 Oct 2009 21:18:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9905562</guid><dc:creator>mab</dc:creator><slash:comments>0</slash:comments><comments>http://blogs.msdn.com/mab/comments/9905562.aspx</comments><wfw:commentRss>http://blogs.msdn.com/mab/commentrss.aspx?PostID=9905562</wfw:commentRss><wfw:comment>http://blogs.msdn.com/mab/rsscomments.aspx?PostID=9905562</wfw:comment><description>&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;B style="mso-bidi-font-weight: normal"&gt;&lt;SPAN style="COLOR: blue"&gt;&lt;FONT face=Verdana&gt;Steps to add programs to Send to folder&lt;?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" /&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/B&gt;&lt;/P&gt;
&lt;OL style="MARGIN-TOP: 0in" type=1&gt;
&lt;LI class=MsoNormal style="MARGIN: 0in 0in 0pt; COLOR: blue; mso-list: l0 level1 lfo1; tab-stops: list .5in"&gt;&lt;FONT face=Verdana&gt;Navigate to your SendTo folder (Windows XP location is C:\Documents and Settings\{user}\SendTo and just replace {user} with your login user name)&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/LI&gt;
&lt;LI class=MsoNormal style="MARGIN: 0in 0in 0pt; COLOR: blue; mso-list: l0 level1 lfo1; tab-stops: list .5in"&gt;&lt;FONT face=Verdana&gt;Right click select New/Shortcut to add a shortcut&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/LI&gt;
&lt;LI class=MsoNormal style="MARGIN: 0in 0in 0pt; COLOR: blue; mso-list: l0 level1 lfo1; tab-stops: list .5in"&gt;&lt;FONT face=Verdana&gt;Type in the location of the program to send the file to then click Next&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/LI&gt;
&lt;OL style="MARGIN-TOP: 0in" type=a&gt;
&lt;LI class=MsoNormal style="MARGIN: 0in 0in 0pt; COLOR: blue; mso-list: l0 level2 lfo1; tab-stops: list 1.0in"&gt;&lt;FONT face=Verdana&gt;Notepad is &lt;SPAN style="BACKGROUND: yellow; mso-highlight: yellow"&gt;“%windir%\notepad.exe”&lt;/SPAN&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/LI&gt;
&lt;LI class=MsoNormal style="MARGIN: 0in 0in 0pt; COLOR: blue; mso-list: l0 level2 lfo1; tab-stops: list 1.0in"&gt;&lt;FONT face=Verdana&gt;Visual Studio 2008 is &lt;SPAN style="BACKGROUND: yellow; mso-highlight: yellow"&gt;"C:\Program Files\Microsoft Visual Studio 9.0\Common7\IDE\devenv.exe" /edit&lt;/SPAN&gt; &lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/LI&gt;&lt;/OL&gt;
&lt;LI class=MsoNormal style="MARGIN: 0in 0in 0pt; COLOR: blue; mso-list: l0 level1 lfo1; tab-stops: list .5in"&gt;&lt;FONT face=Verdana&gt;Give the send to a name that is user friendly (i.e. Notepad or Visual Studio 2008 as appropriate)&lt;/FONT&gt;&lt;/LI&gt;&lt;/OL&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt; COLOR: blue; mso-list: l0 level1 lfo1; tab-stops: list .5in"&gt;&lt;FONT face=Verdana&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=9905562" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/mab/archive/tags/Visual+Studio/default.aspx">Visual Studio</category></item><item><title>TFS Extras Article Created</title><link>http://blogs.msdn.com/mab/archive/2009/10/01/tfs-extras-article-created.aspx</link><pubDate>Thu, 01 Oct 2009 18:51:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9901890</guid><dc:creator>mab</dc:creator><slash:comments>0</slash:comments><comments>http://blogs.msdn.com/mab/comments/9901890.aspx</comments><wfw:commentRss>http://blogs.msdn.com/mab/commentrss.aspx?PostID=9901890</wfw:commentRss><wfw:comment>http://blogs.msdn.com/mab/rsscomments.aspx?PostID=9901890</wfw:comment><description>&lt;P&gt;Started a article that will contain lots of free/commerical add-ons and website articles for TFS.&amp;nbsp;&amp;nbsp; &lt;/P&gt;
&lt;P&gt;Enjoy the first edition: &lt;A href="http://blogs.msdn.com/mab/pages/team-foundation-server-extras.aspx"&gt;http://blogs.msdn.com/mab/pages/team-foundation-server-extras.aspx&lt;/A&gt;&lt;/P&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=9901890" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/mab/archive/tags/Visual+Studio/default.aspx">Visual Studio</category></item><item><title>Free Telerik TFS Manager and Dashboard</title><link>http://blogs.msdn.com/mab/archive/2009/10/01/free-telerik-tfs-manager-and-dashboard.aspx</link><pubDate>Thu, 01 Oct 2009 18:28:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9901874</guid><dc:creator>mab</dc:creator><slash:comments>0</slash:comments><comments>http://blogs.msdn.com/mab/comments/9901874.aspx</comments><wfw:commentRss>http://blogs.msdn.com/mab/commentrss.aspx?PostID=9901874</wfw:commentRss><wfw:comment>http://blogs.msdn.com/mab/rsscomments.aspx?PostID=9901874</wfw:comment><description>&lt;P class=MsoNormal&gt;&lt;FONT face=Verdana size=2&gt;&lt;SPAN style="FONT-SIZE: 10pt"&gt;As a Microsoft VSTS ranger, I come across some interesting TFS add-ons on occasion.&amp;nbsp;&amp;nbsp; The recently introduced Free Telerik TFS Manager and Dashboard tool seems impressive.&amp;nbsp; Most of the features enhance SCRUM/Agile methodology shops but can be used for any methodology.&lt;?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" /&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P class=MsoNormal&gt;&lt;FONT face=Verdana size=2&gt;&lt;SPAN style="FONT-SIZE: 10pt"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P class=MsoNormal&gt;&lt;B&gt;&lt;FONT face=Verdana size=2&gt;&lt;SPAN style="FONT-WEIGHT: bold; FONT-SIZE: 10pt"&gt;Main Page&lt;BR&gt;&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/B&gt;&lt;B&gt;&lt;FONT face=Verdana color=#800080 size=2&gt;&lt;SPAN style="FONT-WEIGHT: bold; FONT-SIZE: 10pt"&gt;&lt;A title=http://www.telerik.com/products/tfsmanager-and-tfsdashboard/tfs-work-item-manager-features.aspx href="http://www.telerik.com/products/tfsmanager-and-tfsdashboard/tfs-work-item-manager-features.aspx" mce_href="http://www.telerik.com/products/tfsmanager-and-tfsdashboard/tfs-work-item-manager-features.aspx"&gt;&lt;SPAN title=http://www.telerik.com/products/tfsmanager-and-tfsdashboard/tfs-work-item-manager-features.aspx style="FONT-WEIGHT: normal"&gt;http://www.telerik.com/products/tfsmanager-and-tfsdashboard/tfs-work-item-manager-features.aspx&lt;/SPAN&gt;&lt;/A&gt;&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/B&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/P&gt;
&lt;P class=MsoNormal&gt;&lt;FONT face=Verdana size=2&gt;&lt;SPAN style="FONT-SIZE: 10pt"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P class=MsoNormal&gt;&lt;B&gt;&lt;FONT face=Verdana size=2&gt;&lt;SPAN style="FONT-WEIGHT: bold; FONT-SIZE: 10pt"&gt;Features&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/B&gt;&lt;/P&gt;
&lt;UL style="MARGIN-TOP: 0in" type=disc&gt;
&lt;LI class=MsoNormal style="mso-list: l0 level1 lfo1"&gt;&lt;FONT face=Verdana size=2&gt;&lt;SPAN style="FONT-SIZE: 10pt"&gt;Work Item grid filtering, grouping, and aggregation &lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/FONT&gt;
&lt;LI class=MsoNormal style="mso-list: l0 level1 lfo1"&gt;&lt;FONT face=Verdana size=2&gt;&lt;SPAN style="FONT-SIZE: 10pt"&gt;Area and Iteration filtering using single and multi select modes &lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/FONT&gt;
&lt;LI class=MsoNormal style="mso-list: l0 level1 lfo1"&gt;&lt;FONT face=Verdana size=2&gt;&lt;SPAN style="FONT-SIZE: 10pt"&gt;Filter query results using a tree of areas or iterations &lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/FONT&gt;
&lt;LI class=MsoNormal style="mso-list: l0 level1 lfo1"&gt;&lt;FONT face=Verdana size=2&gt;&lt;SPAN style="FONT-SIZE: 10pt"&gt;Unique Task board view of work items independent from any process template &lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/FONT&gt;
&lt;LI class=MsoNormal style="mso-list: l0 level1 lfo1"&gt;&lt;FONT face=Verdana size=2&gt;&lt;SPAN style="FONT-SIZE: 10pt"&gt;Print work item cards for the board in your room &lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/FONT&gt;
&lt;LI class=MsoNormal style="mso-list: l0 level1 lfo1"&gt;&lt;FONT face=Verdana size=2&gt;&lt;SPAN style="FONT-SIZE: 10pt"&gt;Iteration schedule &lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/FONT&gt;
&lt;LI class=MsoNormal style="mso-list: l0 level1 lfo1"&gt;&lt;FONT face=Verdana size=2&gt;&lt;SPAN style="FONT-SIZE: 10pt"&gt;Paste as New/Current work item &lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/FONT&gt;
&lt;LI class=MsoNormal style="mso-list: l0 level1 lfo1"&gt;&lt;FONT face=Verdana size=2&gt;&lt;SPAN style="FONT-SIZE: 10pt"&gt;"New by example" saves your query for other team members &lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/FONT&gt;
&lt;LI class=MsoNormal style="mso-list: l0 level1 lfo1"&gt;&lt;FONT face=Verdana size=2&gt;&lt;SPAN style="FONT-SIZE: 10pt"&gt;Search the title and description of query results as you type&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/FONT&gt; &lt;/LI&gt;&lt;/UL&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=9901874" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/mab/archive/tags/Visual+Studio/default.aspx">Visual Studio</category></item><item><title>How to close window (self) without prompting in IE6 and IE7</title><link>http://blogs.msdn.com/mab/archive/2009/08/25/how-to-close-window-self-without-prompting-in-ie6-and-ie7.aspx</link><pubDate>Wed, 26 Aug 2009 00:06:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9884140</guid><dc:creator>mab</dc:creator><slash:comments>0</slash:comments><comments>http://blogs.msdn.com/mab/comments/9884140.aspx</comments><wfw:commentRss>http://blogs.msdn.com/mab/commentrss.aspx?PostID=9884140</wfw:commentRss><wfw:comment>http://blogs.msdn.com/mab/rsscomments.aspx?PostID=9884140</wfw:comment><description>&lt;P&gt;&lt;STRONG&gt;Scenario&lt;BR&gt;&lt;/STRONG&gt;Web application wants to pop-up a window as a certain size, chromeless, etc.&amp;nbsp; However doesn't want to have the opening (parent) window show.&amp;nbsp; Common usages are launching from shortcut or an application.&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;Solution&lt;BR&gt;&lt;/STRONG&gt;In the "parent" page that launches the popup.&amp;nbsp;&amp;nbsp; Put the following code to close your(self) in javascript:&lt;FONT color=#000080&gt;&amp;nbsp;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color=#000080&gt;var self2 = window.open("", "_self"); &lt;BR&gt;self2.focus(); &lt;BR&gt;self2.opener = self2; &lt;BR&gt;self2.close();&lt;/P&gt;&lt;/FONT&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=9884140" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/mab/archive/tags/Internet+Explorer/default.aspx">Internet Explorer</category></item><item><title>How to autoresize parent frame height from child frame</title><link>http://blogs.msdn.com/mab/archive/2009/06/12/how-to-autoresize-parent-frame-height-from-child-frame.aspx</link><pubDate>Sat, 13 Jun 2009 02:01:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9740315</guid><dc:creator>mab</dc:creator><slash:comments>0</slash:comments><comments>http://blogs.msdn.com/mab/comments/9740315.aspx</comments><wfw:commentRss>http://blogs.msdn.com/mab/commentrss.aspx?PostID=9740315</wfw:commentRss><wfw:comment>http://blogs.msdn.com/mab/rsscomments.aspx?PostID=9740315</wfw:comment><description>&lt;P&gt;&lt;STRONG&gt;Scenario&lt;/STRONG&gt;&lt;BR&gt;A parent document contains a frame that loads a file which content is dynamic and you want the frame to not scroll and autosize the height of the frame.&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;Solution&lt;BR&gt;&lt;/STRONG&gt;function autoResizeParent() {&lt;/P&gt;
&lt;BLOCKQUOTE&gt;
&lt;P&gt;// if no parent don't attempt to change&lt;BR&gt;if (parent != null) {&lt;/P&gt;&lt;/BLOCKQUOTE&gt;
&lt;BLOCKQUOTE&gt;
&lt;BLOCKQUOTE&gt;
&lt;P&gt;var frameList = parent.document.body.getElementsByTagName("iframe");&lt;/P&gt;&lt;/BLOCKQUOTE&gt;
&lt;BLOCKQUOTE&gt;
&lt;P&gt;// is there any frames?&lt;/P&gt;
&lt;P&gt;if (frameList != null) {&lt;/P&gt;
&lt;BLOCKQUOTE&gt;
&lt;P&gt;for (var i = 0; i &amp;lt; frameList.length; i++) {&lt;/P&gt;
&lt;BLOCKQUOTE&gt;
&lt;P&gt;var srcName = frameList[i].src;&lt;/P&gt;
&lt;P&gt;srcName = srcName.substr(srcName.lastIndexOf("/"));&lt;/P&gt;
&lt;P&gt;var srcParent = document.location.pathname.substr(document.location.pathname.lastIndexOf("/"));&lt;/P&gt;
&lt;P&gt;alert("Parent=" + srcParent + "\nFrame="+ srcName);&lt;/P&gt;
&lt;P&gt;// found myself&lt;/P&gt;
&lt;P&gt;if (srcParent == srcName) {&lt;/P&gt;
&lt;BLOCKQUOTE&gt;
&lt;P&gt;// set parent frame height to my height&lt;/P&gt;
&lt;P&gt;frameList[i].height = document.body.offsetHeight;&lt;/P&gt;
&lt;P&gt;// force scrolling off&lt;/P&gt;
&lt;P&gt;frameList[i].scrolling = "no";&lt;/P&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;}&lt;/P&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;}&lt;/P&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;}&lt;/P&gt;&lt;/BLOCKQUOTE&gt;&lt;/BLOCKQUOTE&gt;
&lt;BLOCKQUOTE&gt;
&lt;P&gt;}&lt;/P&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;}&lt;/P&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=9740315" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/mab/archive/tags/Internet+Explorer/default.aspx">Internet Explorer</category><category domain="http://blogs.msdn.com/mab/archive/tags/Visual+Studio/default.aspx">Visual Studio</category></item><item><title>How to access SQL Server on Windows through a secure connection from Perl on Linux</title><link>http://blogs.msdn.com/mab/archive/2009/06/04/how-to-access-sql-server-through-a-secure-connection-from-perl.aspx</link><pubDate>Fri, 05 Jun 2009 03:17:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9700508</guid><dc:creator>mab</dc:creator><slash:comments>0</slash:comments><comments>http://blogs.msdn.com/mab/comments/9700508.aspx</comments><wfw:commentRss>http://blogs.msdn.com/mab/commentrss.aspx?PostID=9700508</wfw:commentRss><wfw:comment>http://blogs.msdn.com/mab/rsscomments.aspx?PostID=9700508</wfw:comment><description>&lt;P&gt;&lt;STRONG&gt;Scenario&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;Have some perl code that wants to access Microsoft SQL Server 2005.&amp;nbsp;&amp;nbsp; The SQL Server is configured to only allow SSL connections for security reasons.&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;Solution&lt;/STRONG&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Here are the parts you will need:&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;Perl on Linux (given)&lt;/LI&gt;
&lt;LI&gt;DBI ... &lt;A href="http://dbi.perl.org/" mce_href="http://dbi.perl.org/"&gt;http://dbi.perl.org/&lt;/A&gt;&lt;/LI&gt;
&lt;LI&gt;Unix ODBC (or equivalent like iODBC) ... &lt;A href="http://www.unixodbc.org/" mce_href="http://www.unixodbc.org/"&gt;http://www.unixodbc.org/&lt;/A&gt;&lt;/LI&gt;
&lt;LI&gt;FreeTDS (or equivalent ODBC driver) ... &lt;A href="http://www.freetds.org/" mce_href="http://www.freetds.org/"&gt;http://www.freetds.org/&lt;/A&gt;&lt;/LI&gt;
&lt;LI&gt;OpenSSL ... &lt;A href="http://www.openssl.org/" mce_href="http://www.openssl.org/"&gt;http://www.openssl.org/&lt;/A&gt;&lt;/LI&gt;
&lt;LI&gt;TLS &lt;/LI&gt;&lt;/UL&gt;
&lt;P&gt;&lt;STRONG&gt;Resources&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;Microsoft guidance on accessing SQL Server with Perl&lt;BR&gt;&lt;A href="http://technet.microsoft.com/en-us/library/bb497071.aspx" mce_href="http://technet.microsoft.com/en-us/library/bb497071.aspx"&gt;http://technet.microsoft.com/en-us/library/bb497071.aspx&lt;/A&gt;&amp;nbsp;&lt;/P&gt;
&lt;P mce_keep="true"&gt;Thanks for Brian on helping figure this out :) ... I am just&amp;nbsp;the messenger.&lt;/P&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=9700508" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/mab/archive/tags/SQL+Server/default.aspx">SQL Server</category><category domain="http://blogs.msdn.com/mab/archive/tags/Perl/default.aspx">Perl</category></item><item><title>Windows 2008 R2 Hyper-V and Remote Desktop</title><link>http://blogs.msdn.com/mab/archive/2009/05/28/windows-2008-r2-hyper-v-and-remote-desktop.aspx</link><pubDate>Thu, 28 May 2009 17:50:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9647383</guid><dc:creator>mab</dc:creator><slash:comments>2</slash:comments><comments>http://blogs.msdn.com/mab/comments/9647383.aspx</comments><wfw:commentRss>http://blogs.msdn.com/mab/commentrss.aspx?PostID=9647383</wfw:commentRss><wfw:comment>http://blogs.msdn.com/mab/rsscomments.aspx?PostID=9647383</wfw:comment><description>&lt;P&gt;&lt;STRONG&gt;Scenario&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;Download your favorite image (or create one) and you want to exchange files with the guest OS.&amp;nbsp;&amp;nbsp; You are running Wi-fi and have to use the wired connection as your virtual network.&amp;nbsp;&amp;nbsp; You can access your image just fine through the Hyper-V Virtual Machine connection app but it doesn't support accessing host folders.&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;Solution&amp;nbsp;&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;Remote Desktop to the rescue!&amp;nbsp;&amp;nbsp; Yes I know, this is old news, but read on for the problem you may encounter.&amp;nbsp;&amp;nbsp; &lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;Problem&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;You&amp;nbsp;start up remote desktop and try to access via IP and/or host name and you get that it is not there.&amp;nbsp;&amp;nbsp; Hmmm....&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;Real Solution&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;The problem may be that by default Remote Desktop will try to auto-detect a remote desktop gateway.&amp;nbsp;&amp;nbsp; When you are connected to the internet or you LAN you may encounter one!&amp;nbsp;&amp;nbsp;&amp;nbsp; Just go over to the options/Advanced and choose to NOT use a gateway and voila!&amp;nbsp;it works!&lt;/P&gt;
&lt;P&gt;Now you can change your settings to share local host drives with your remote session (your guest VM) and start sharing!&lt;/P&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=9647383" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/mab/archive/tags/Hyper-V/default.aspx">Hyper-V</category><category domain="http://blogs.msdn.com/mab/archive/tags/Windows+Server+2008/default.aspx">Windows Server 2008</category></item><item><title>How to recycle a IIS6 website in Windows Server 2003 SP1</title><link>http://blogs.msdn.com/mab/archive/2009/04/20/how-to-recycle-a-iis6-website-in-windows-server-2003-sp1.aspx</link><pubDate>Mon, 20 Apr 2009 21:30:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9557085</guid><dc:creator>mab</dc:creator><slash:comments>1</slash:comments><comments>http://blogs.msdn.com/mab/comments/9557085.aspx</comments><wfw:commentRss>http://blogs.msdn.com/mab/commentrss.aspx?PostID=9557085</wfw:commentRss><wfw:comment>http://blogs.msdn.com/mab/rsscomments.aspx?PostID=9557085</wfw:comment><description>&lt;P&gt;Many clients I have worked with simply use the IISReset.exe command to recycle applications.&amp;nbsp; Although this may have the desired affect sometimes, there are many alternatives that are better.&amp;nbsp;By no means is this an exhaustive list but will give you some options when a specific website is causing problems (i.e. hung, OOM).&amp;nbsp;&amp;nbsp; Stopping a website doesn't reset memory or the worker process it just stops the website from processing the requests.&amp;nbsp;&amp;nbsp; Therefore, the website "start/stop" actions are not listed below.&lt;/P&gt;
&lt;P&gt;&lt;SPAN class=077585517-20042009&gt;&lt;FONT face=Verdana size=2&gt;&lt;STRONG&gt;Single Web Application "resets"&lt;/STRONG&gt;&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;OL&gt;
&lt;LI&gt;&lt;SPAN class=077585517-20042009&gt;&lt;FONT face=Verdana size=2&gt;&lt;STRONG&gt;Recommended:&lt;/STRONG&gt; Recycle the application pool of the specific website's application pool.&amp;nbsp; With Windows Server 2003 SP1 the command line is iisapp.vbs:&amp;nbsp; Reference: &lt;A href="http://blogs.iis.net/chrisad/archive/2006/08/30/Recycling-Application-Pools-using-WMI-in-IIS-6.0.aspx" mce_href="http://blogs.iis.net/chrisad/archive/2006/08/30/Recycling-Application-Pools-using-WMI-in-IIS-6.0.aspx"&gt;http://blogs.iis.net/chrisad/archive/2006/08/30/Recycling-Application-Pools-using-WMI-in-IIS-6.0.aspx&lt;/A&gt;.&amp;nbsp; You can use a process id /p or an application id with /a.&amp;nbsp;&lt;BR&gt;&lt;BR&gt;Examples:&lt;BR&gt;&lt;/FONT&gt;&lt;/SPAN&gt;&lt;SPAN class=077585517-20042009&gt;&lt;FONT face=Verdana size=2&gt;D:\WINDOWS&amp;gt;&lt;STRONG&gt;iisapp /p 596 /r&amp;nbsp;&lt;BR&gt;&lt;/STRONG&gt;Microsoft (R) Windows Script Host Version 5.6&lt;BR&gt;Copyright (C) Microsoft Corporation 1996-2001. All rights reserved.&lt;BR&gt;Application pool 'DefaultAppPool' recycled successfully.&lt;BR&gt;&lt;BR&gt;D:\WINDOWS&amp;gt;&lt;STRONG&gt;iisapp /a DefaultAppPool /r&lt;/STRONG&gt;&lt;BR&gt;Microsoft (R) Windows Script Host Version 5.6&lt;BR&gt;Copyright (C) Microsoft Corporation 1996-2001. All rights reserved.&lt;BR&gt;Application pool 'DefaultAppPool' recycled successfully.&lt;/LI&gt;&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/OL&gt;
&lt;DIV&gt;&lt;SPAN class=077585517-20042009&gt;&lt;FONT face=Verdana size=2&gt;&lt;STRONG&gt;Reseting &lt;EM&gt;&lt;U&gt;ALL&lt;/U&gt;&lt;/EM&gt; websites on a server&amp;nbsp;(not recommended)&lt;/STRONG&gt;&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/DIV&gt;
&lt;OL&gt;
&lt;LI&gt;&lt;SPAN class=077585517-20042009&gt;&lt;FONT face=Verdana size=2&gt;&lt;STRONG&gt;Start and stop specific&amp;nbsp;services &lt;/STRONG&gt;for web services only (do not do the start commands if you are not recycling)&lt;BR&gt;&lt;/FONT&gt;&lt;/SPAN&gt;&lt;SPAN class=077585517-20042009&gt;&lt;FONT face=Verdana size=2&gt;NET STOP W3SVC&lt;BR&gt;NET STOP HTTPFilter &lt;EM&gt;(if having problems with SSL)&lt;BR&gt;&lt;/EM&gt;NET START HTTPFilter &lt;EM&gt;(if having problems with SSL)&lt;/EM&gt;&lt;BR&gt;NET START W3SVC&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/LI&gt;
&lt;LI&gt;&lt;SPAN class=077585517-20042009&gt;&lt;/SPAN&gt;&lt;SPAN class=077585517-20042009&gt;&lt;FONT face=Verdana size=2&gt;Use &lt;STRONG&gt;IISReset /NOFORCE&lt;/STRONG&gt;&amp;nbsp;, this causes the system to not forceable terminate the internet services if timeout or error occurs.&amp;nbsp; Note: this will reset all IIS services that are enabled: FTP, NNTP, WWW, IISAdmin, etc.&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/LI&gt;
&lt;LI&gt;&lt;SPAN class=077585517-20042009&gt;&lt;FONT face=Verdana size=2&gt;&lt;STRONG&gt;IISReset&lt;/STRONG&gt; (without /NOFORCE) causes a forceable stop if doesn't respond within 60s (the&amp;nbsp;stop default can be changed via command line).&amp;nbsp; This may lead to IIS configuration loss (&lt;A href="http://support.microsoft.com/kb/286196" mce_href="http://support.microsoft.com/kb/286196"&gt;http://support.microsoft.com/kb/286196&lt;/A&gt;). Note: this will reset all IIS services that are enabled: FTP, NNTP, WWW, IISAdmin, etc.&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/LI&gt;
&lt;LI&gt;&lt;SPAN class=077585517-20042009&gt;&lt;FONT face=Verdana size=2&gt;&lt;STRONG&gt;Reboot&lt;/STRONG&gt; the server.&amp;nbsp; Not recommended and may cause signficant data loss.&amp;nbsp; Note: this attempts to shutdown or forcably shutdown all applications on the server not just IIS related.&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/LI&gt;
&lt;LI&gt;&lt;SPAN class=077585517-20042009&gt;&lt;FONT face=Verdana size=2&gt;&lt;STRONG&gt;Power cycle&lt;/STRONG&gt; the server.&amp;nbsp; Not recommended and may cause signficant data loss.&amp;nbsp; Note: this is extremely dangerous and only to be used when all other options (even one's not listed above) have been tried.&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/LI&gt;&lt;/OL&gt;
&lt;P&gt;&lt;SPAN class=077585517-20042009&gt;&amp;nbsp;&lt;FONT face=Verdana&gt;Hope this helps ...&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=9557085" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/mab/archive/tags/Internet+Explorer/default.aspx">Internet Explorer</category><category domain="http://blogs.msdn.com/mab/archive/tags/IIS/default.aspx">IIS</category></item><item><title>Install a remote printer via a Hyperlink in HTML</title><link>http://blogs.msdn.com/mab/archive/2009/02/13/install-a-remote-printer-via-a-hyperlink-in-html.aspx</link><pubDate>Fri, 13 Feb 2009 18:03:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9418966</guid><dc:creator>mab</dc:creator><slash:comments>2</slash:comments><comments>http://blogs.msdn.com/mab/comments/9418966.aspx</comments><wfw:commentRss>http://blogs.msdn.com/mab/commentrss.aspx?PostID=9418966</wfw:commentRss><wfw:comment>http://blogs.msdn.com/mab/rsscomments.aspx?PostID=9418966</wfw:comment><description>&lt;P&gt;Ever tried to install a printer by just giving users a link?&amp;nbsp;&amp;nbsp;Well here is a small snippet of one way to do this.&amp;nbsp;&amp;nbsp; Please note that since you are interacting with the OS (outside the browser) that you may receive security warnings.&amp;nbsp;&amp;nbsp; This has been tested on Vista SP1 x86 32 bit with IE7.&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;Code&lt;BR&gt;&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;&amp;lt;html&amp;gt;&lt;BR&gt;&amp;lt;head&amp;gt;&lt;BR&gt;&amp;lt;script type="text/vbscript"&amp;gt;&lt;BR&gt;function AddP(pName)&lt;BR&gt;msgbox "Start"&lt;BR&gt;Set WshNetwork = CreateObject("Wscript.Network")&lt;BR&gt;WshNetwork.AddWindowsPrinterConnection pName&lt;BR&gt;msgbox "Finished"&lt;BR&gt;end function&lt;BR&gt;&amp;lt;/script&amp;gt;&lt;BR&gt;&amp;lt;/head&amp;gt;&lt;BR&gt;&amp;lt;body&amp;gt;&lt;BR&gt;&amp;lt;a href='#' language="vbscript" onclick="AddP('\\Home-PC\HP Photosmart 3300 series')"&amp;gt;Add printer&amp;lt;/a&amp;gt;&lt;BR&gt;&amp;lt;/body&amp;gt;&lt;BR&gt;&amp;lt;/html&amp;gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;Please note that above the a href should be ="#" not single quotes.&lt;/P&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=9418966" width="1" height="1"&gt;</description></item><item><title>Using Visual Studio with IIS7 on Vista and Win 7</title><link>http://blogs.msdn.com/mab/archive/2009/02/10/using-visual-studio-with-iis7-on-vista-and-win-7.aspx</link><pubDate>Tue, 10 Feb 2009 21:08:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9411026</guid><dc:creator>mab</dc:creator><slash:comments>1</slash:comments><comments>http://blogs.msdn.com/mab/comments/9411026.aspx</comments><wfw:commentRss>http://blogs.msdn.com/mab/commentrss.aspx?PostID=9411026</wfw:commentRss><wfw:comment>http://blogs.msdn.com/mab/rsscomments.aspx?PostID=9411026</wfw:comment><description>&lt;P&gt;For those interested in installing VSTS and using with IIS7 on Vista (and possible with Win 7) you should follow the following instructions:&lt;/P&gt;
&lt;P&gt;&lt;A href="http://msdn.microsoft.com/en-us/library/aa964620.aspx"&gt;http://msdn.microsoft.com/en-us/library/aa964620.aspx&lt;/A&gt;&lt;/P&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=9411026" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/mab/archive/tags/Visual+Studio/default.aspx">Visual Studio</category></item><item><title>How to do logic OR AND NOT across rows in SQL</title><link>http://blogs.msdn.com/mab/archive/2008/12/15/how-to-do-logic-or-and-not-across-rows-in-sql.aspx</link><pubDate>Mon, 15 Dec 2008 20:02:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9221520</guid><dc:creator>mab</dc:creator><slash:comments>0</slash:comments><comments>http://blogs.msdn.com/mab/comments/9221520.aspx</comments><wfw:commentRss>http://blogs.msdn.com/mab/commentrss.aspx?PostID=9221520</wfw:commentRss><wfw:comment>http://blogs.msdn.com/mab/rsscomments.aspx?PostID=9221520</wfw:comment><description>&lt;P&gt;Scenario&lt;/P&gt;
&lt;P&gt;You have a normalized table that has values in rows.&amp;nbsp;&amp;nbsp; Let's take an example that has a history table with an approved flag:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;Date&amp;nbsp; Approved&amp;nbsp; DollarValue&amp;nbsp; Customer&lt;BR&gt;1/1/2008&amp;nbsp; Y&amp;nbsp;&amp;nbsp;&amp;nbsp; 13.5&amp;nbsp;&amp;nbsp;&amp;nbsp; A&lt;BR&gt;2/1/2008&amp;nbsp; N&amp;nbsp;&amp;nbsp;&amp;nbsp; 12&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; A&lt;BR&gt;3/1/2008&amp;nbsp; Y&amp;nbsp;&amp;nbsp;&amp;nbsp; 14&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; A&lt;/P&gt;
&lt;P&gt;1/1/2008&amp;nbsp; Y&amp;nbsp;&amp;nbsp;&amp;nbsp; 11.5&amp;nbsp;&amp;nbsp;&amp;nbsp; B&lt;BR&gt;2/1/2008&amp;nbsp; Y&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;9&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; B&lt;BR&gt;3/1/2008&amp;nbsp; Y&amp;nbsp;&amp;nbsp;&amp;nbsp; 17&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; B&lt;/P&gt;
&lt;P&gt;1/1/2008&amp;nbsp; Y&amp;nbsp;&amp;nbsp;&amp;nbsp; 13.5&amp;nbsp;&amp;nbsp;&amp;nbsp; C&lt;BR&gt;2/1/2008&amp;nbsp; Y&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;29&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; C&lt;BR&gt;3/1/2008&amp;nbsp; Y&amp;nbsp;&amp;nbsp;&amp;nbsp; 18&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;C&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You want to find know if all the customers with all 3 monthly values approved and the values are &amp;lt; 20.&amp;nbsp;&amp;nbsp;&amp;nbsp; Now I know you can get at this result multiple ways but I just want to show how you can apply logic across rows.&lt;/P&gt;
&lt;P&gt;First you know that there are 3 monthly records for all the months data and you are also looking for an approved.&lt;/P&gt;
&lt;P&gt;SELECT DISTINCT Customer &lt;BR&gt;FROM MyTable &lt;BR&gt;WHERE Approved = 'Y' AND DollarValue &amp;lt; 20&lt;BR&gt;GROUP BY Customer&lt;BR&gt;HAVING COUNT(Customer) = 3&lt;/P&gt;
&lt;P&gt;You should see an output with only Customer B.&lt;/P&gt;
&lt;P&gt;Similar techniques can be applied for OR and NOT.&lt;/P&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=9221520" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/mab/archive/tags/SQL+Server/default.aspx">SQL Server</category></item><item><title>Custom Security and SQL Job with SSIS Script Task</title><link>http://blogs.msdn.com/mab/archive/2008/11/06/custom-security-and-sql-job-with-ssis-script-task.aspx</link><pubDate>Fri, 07 Nov 2008 00:18:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9050591</guid><dc:creator>mab</dc:creator><slash:comments>1</slash:comments><comments>http://blogs.msdn.com/mab/comments/9050591.aspx</comments><wfw:commentRss>http://blogs.msdn.com/mab/commentrss.aspx?PostID=9050591</wfw:commentRss><wfw:comment>http://blogs.msdn.com/mab/rsscomments.aspx?PostID=9050591</wfw:comment><description>&lt;P&gt;&lt;STRONG&gt;Scenario&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;Recently I ran into a security issue that has a simple fix.&amp;nbsp; Here is the situation:&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;SSIS Package that contains a Script Task&lt;/LI&gt;
&lt;LI&gt;Run SSIS package as a SQL Job&lt;/LI&gt;
&lt;LI&gt;Use a special credential/proxy for the step of executing the SSIS package&lt;/LI&gt;&lt;/UL&gt;
&lt;P&gt;&lt;STRONG&gt;Results&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;&lt;EM&gt;In the SQL Job History Log you may find something like this ...&lt;BR&gt;&lt;/EM&gt;Code: 0x00000002&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Source: XXXXX Script Task&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Description: The script threw an exception: Unable to generate a temporary class (result=1).&amp;nbsp; error CS2001: Source file 'C:\WINDOWS\TEMP\yyyzzzxxx.N.cs' could not be found&amp;nbsp; error CS2008: No inputs specified&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;Solution&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;Simple put,the VBA compiler has permissions to write the file into C:\windows\temp but your credential does not.&amp;nbsp;&amp;nbsp; Now the simple fix is to allow just read/read&amp;amp;execute/list permissions to C:\windows\temp and that will resolve the issue above.&amp;nbsp;&amp;nbsp; However, please not that there is a potential security risk in doing so as that this credential now has access to read all temp files in this directory.&amp;nbsp;&amp;nbsp; So be forewarned that this may not fit your situation.&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;Conclusion&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;Although not suggesting the ideal security solution, this may help you troubleshoot and further refine your strategy in running you SSIS package with a Script task with a custom credential/proxy.&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;&lt;/STRONG&gt;&amp;nbsp;&lt;/P&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=9050591" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/mab/archive/tags/SQL+Server/default.aspx">SQL Server</category></item><item><title>Optimizing queries with joins and over statements in SQL 2005</title><link>http://blogs.msdn.com/mab/archive/2008/07/29/optimizing-queries-with-joins-and-over-statements-in-sql-2005.aspx</link><pubDate>Tue, 29 Jul 2008 09:27:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:8787430</guid><dc:creator>mab</dc:creator><slash:comments>1</slash:comments><comments>http://blogs.msdn.com/mab/comments/8787430.aspx</comments><wfw:commentRss>http://blogs.msdn.com/mab/commentrss.aspx?PostID=8787430</wfw:commentRss><wfw:comment>http://blogs.msdn.com/mab/rsscomments.aspx?PostID=8787430</wfw:comment><description>&lt;FONT color=#ff0000&gt;&lt;FONT size=2&gt;
&lt;P class=MsoNormal style="MARGIN: 5pt 0in; mso-layout-grid-align: none"&gt;&lt;SPAN style="FONT-SIZE: 12pt; FONT-FAMILY: 'Times New Roman'"&gt;&lt;FONT color=#000000&gt;I was working on a common scenario and found an interesting side effect. Applications typically have a listing page that get search criteria from a UI and passes to a stored procedure. In the procedure you often find statements like:&lt;?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" /&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 5pt 0in; mso-layout-grid-align: none"&gt;&lt;SPAN style="FONT-SIZE: 10pt; COLOR: blue; FONT-FAMILY: 'Courier New'"&gt;SELECT&lt;/SPAN&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'"&gt;&lt;FONT color=#000000&gt; a&lt;/FONT&gt;&lt;SPAN style="COLOR: gray"&gt;,&lt;/SPAN&gt;&lt;FONT color=#000000&gt;b&lt;/FONT&gt;&lt;SPAN style="COLOR: gray"&gt;,&lt;/SPAN&gt;&lt;FONT color=#000000&gt;c&lt;/FONT&gt;&lt;SPAN style="COLOR: gray"&gt;,&lt;/SPAN&gt;&lt;FONT color=#000000&gt;d &lt;BR&gt;&lt;/FONT&gt;&lt;SPAN style="COLOR: blue"&gt;FROM&lt;/SPAN&gt;&lt;FONT color=#000000&gt; MyTable&lt;BR&gt;&lt;/FONT&gt;&lt;SPAN style="COLOR: blue"&gt;WHERE&lt;/SPAN&gt;&lt;FONT color=#000000&gt; c &lt;/FONT&gt;&lt;SPAN style="COLOR: gray"&gt;=&lt;/SPAN&gt;&lt;FONT color=#000000&gt; @SearchC &lt;/FONT&gt;&lt;SPAN style="COLOR: gray"&gt;AND&lt;/SPAN&gt;&lt;FONT color=#000000&gt; d &lt;/FONT&gt;&lt;SPAN style="COLOR: gray"&gt;=&lt;/SPAN&gt;&lt;FONT color=#000000&gt; @SearchD&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 5pt 0in; mso-layout-grid-align: none"&gt;&lt;SPAN style="FONT-SIZE: 12pt; FONT-FAMILY: 'Times New Roman'"&gt;&lt;FONT color=#000000&gt;Often times you need to join information to the main data that is the most current from a historical table. For example in SQL 2005.&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 5pt 0in; mso-layout-grid-align: none"&gt;&lt;SPAN style="FONT-SIZE: 10pt; COLOR: blue; FONT-FAMILY: 'Courier New'"&gt;SELECT&lt;/SPAN&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'"&gt;&lt;FONT color=#000000&gt; t&lt;/FONT&gt;&lt;SPAN style="COLOR: gray"&gt;.*&lt;BR&gt;&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;FROM&lt;BR&gt;&lt;/SPAN&gt;&lt;SPAN style="COLOR: gray"&gt;(&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;SELECT&lt;/SPAN&gt;&lt;FONT color=#000000&gt; &lt;BR&gt;ID&lt;BR&gt;&lt;/FONT&gt;&lt;SPAN style="COLOR: gray"&gt;,&lt;/SPAN&gt;&lt;FONT color=#000000&gt; Amt&lt;BR&gt;&lt;/FONT&gt;&lt;SPAN style="COLOR: gray"&gt;,&lt;/SPAN&gt;&lt;FONT color=#000000&gt; AmtDepositDate&lt;BR&gt;&lt;/FONT&gt;&lt;SPAN style="COLOR: gray"&gt;,&lt;/SPAN&gt;&lt;FONT color=#000000&gt; &lt;/FONT&gt;&lt;SPAN style="COLOR: fuchsia"&gt;row_number&lt;/SPAN&gt;&lt;SPAN style="COLOR: gray"&gt;()&lt;/SPAN&gt;&lt;FONT color=#000000&gt; &lt;/FONT&gt;&lt;SPAN style="COLOR: blue"&gt;over&lt;/SPAN&gt;&lt;FONT color=#000000&gt; &lt;/FONT&gt;&lt;SPAN style="COLOR: gray"&gt;(&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;partition&lt;/SPAN&gt;&lt;FONT color=#000000&gt; &lt;/FONT&gt;&lt;SPAN style="COLOR: blue"&gt;by&lt;/SPAN&gt;&lt;FONT color=#000000&gt; ID &lt;/FONT&gt;&lt;SPAN style="COLOR: blue"&gt;order&lt;/SPAN&gt;&lt;FONT color=#000000&gt; &lt;/FONT&gt;&lt;SPAN style="COLOR: blue"&gt;by&lt;/SPAN&gt;&lt;FONT color=#000000&gt; ID&lt;/FONT&gt;&lt;SPAN style="COLOR: gray"&gt;,&lt;/SPAN&gt;&lt;FONT color=#000000&gt; AmtDepositDate &lt;/FONT&gt;&lt;SPAN style="COLOR: blue"&gt;desc&lt;/SPAN&gt;&lt;SPAN style="COLOR: gray"&gt;)&lt;/SPAN&gt;&lt;FONT color=#000000&gt; &lt;/FONT&gt;&lt;SPAN style="COLOR: blue"&gt;as&lt;/SPAN&gt;&lt;FONT color=#000000&gt; rn &lt;BR&gt;&lt;/FONT&gt;&lt;SPAN style="COLOR: blue"&gt;FROM&lt;/SPAN&gt;&lt;FONT color=#000000&gt; MoneyTable&lt;BR&gt;&lt;/FONT&gt;&lt;SPAN style="COLOR: gray"&gt;)&lt;/SPAN&gt;&lt;FONT color=#000000&gt; t&lt;BR&gt;&lt;/FONT&gt;&lt;SPAN style="COLOR: blue"&gt;WHERE&lt;/SPAN&gt;&lt;FONT color=#000000&gt; rn&lt;/FONT&gt;&lt;SPAN style="COLOR: gray"&gt;=&lt;/SPAN&gt;&lt;FONT color=#000000&gt;1&lt;/FONT&gt;&lt;/SPAN&gt;&lt;SPAN style="FONT-SIZE: 12pt; FONT-FAMILY: 'Times New Roman'"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 5pt 0in; mso-layout-grid-align: none"&gt;&lt;SPAN style="FONT-SIZE: 12pt; COLOR: black; FONT-FAMILY: 'Times New Roman'"&gt;I found that when you join the above query to the main search query above a weird optimization occurs in SQL 2005. I suspect (unconfirmed with product group) that a left join can't optmize the query with the over so it ends up do a sub select on all records every row in the main search.&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 5pt 0in; mso-layout-grid-align: none"&gt;&lt;SPAN style="FONT-SIZE: 12pt; COLOR: black; FONT-FAMILY: 'Times New Roman'"&gt;The solution (in my case where there is small sets of data of &amp;lt; 5000 records), I create a table variable and select into the lasted record from the history table. Then I join the table variable to the main table search.&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 5pt 0in; mso-layout-grid-align: none"&gt;&lt;SPAN style="FONT-SIZE: 12pt; COLOR: black; FONT-FAMILY: 'Times New Roman'"&gt;In my scenario with 2000 main records and 1 million history records the left join with the latest select (no table variable) took 5+ minutes. Using the table variables took 2 seconds for everything.&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 5pt 0in; mso-layout-grid-align: none"&gt;&lt;SPAN style="FONT-SIZE: 12pt; COLOR: black; FONT-FAMILY: 'Times New Roman'"&gt;Here is a snippet of the overall solution:&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 5pt 0in; mso-layout-grid-align: none"&gt;&lt;SPAN style="FONT-SIZE: 10pt; COLOR: blue; FONT-FAMILY: 'Courier New'"&gt;DECLARE&lt;/SPAN&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'"&gt;&lt;FONT color=#000000&gt; @MyTable &lt;/FONT&gt;&lt;SPAN style="COLOR: blue"&gt;table&lt;/SPAN&gt;&lt;FONT color=#000000&gt; &lt;/FONT&gt;&lt;SPAN style="COLOR: gray"&gt;(&lt;BR&gt;&lt;/SPAN&gt;&lt;FONT color=#000000&gt;&lt;SPAN style="mso-tab-count: 1"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;ID &lt;/FONT&gt;&lt;SPAN style="COLOR: blue"&gt;int&lt;BR&gt;&lt;/SPAN&gt;&lt;SPAN style="mso-tab-count: 1"&gt;&lt;FONT color=#000000&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/FONT&gt;&lt;/SPAN&gt;&lt;SPAN style="COLOR: gray"&gt;,&lt;/SPAN&gt;&lt;FONT color=#000000&gt;Amt &lt;/FONT&gt;&lt;SPAN style="COLOR: blue"&gt;float&lt;BR&gt;&lt;/SPAN&gt;&lt;SPAN style="mso-tab-count: 1"&gt;&lt;FONT color=#000000&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/FONT&gt;&lt;/SPAN&gt;&lt;SPAN style="COLOR: gray"&gt;,&lt;/SPAN&gt;&lt;FONT color=#000000&gt;AmtDepositDate &lt;/FONT&gt;&lt;SPAN style="COLOR: blue"&gt;datetime&lt;BR&gt;&lt;/SPAN&gt;&lt;SPAN style="mso-tab-count: 1"&gt;&lt;FONT color=#000000&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/FONT&gt;&lt;/SPAN&gt;&lt;SPAN style="COLOR: gray"&gt;)&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 5pt 0in; mso-layout-grid-align: none"&gt;&lt;SPAN style="FONT-SIZE: 10pt; COLOR: blue; FONT-FAMILY: 'Courier New'"&gt;INSERT&lt;/SPAN&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'"&gt;&lt;FONT color=#000000&gt; &lt;/FONT&gt;&lt;SPAN style="COLOR: blue"&gt;INTO&lt;/SPAN&gt;&lt;FONT color=#000000&gt; @MyTable&lt;BR&gt;&lt;/FONT&gt;&lt;SPAN style="COLOR: blue"&gt;SELECT&lt;BR&gt;&lt;/SPAN&gt;&lt;FONT color=#000000&gt;&lt;SPAN style="mso-tab-count: 1"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;t&lt;/FONT&gt;&lt;SPAN style="COLOR: gray"&gt;.&lt;/SPAN&gt;&lt;FONT color=#000000&gt;ID &lt;BR&gt;&lt;SPAN style="mso-tab-count: 1"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;/FONT&gt;&lt;SPAN style="COLOR: gray"&gt;,&lt;/SPAN&gt;&lt;FONT color=#000000&gt;t&lt;/FONT&gt;&lt;SPAN style="COLOR: gray"&gt;.&lt;/SPAN&gt;&lt;FONT color=#000000&gt;Amt&lt;BR&gt;&lt;SPAN style="mso-tab-count: 1"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;/FONT&gt;&lt;SPAN style="COLOR: gray"&gt;,&lt;/SPAN&gt;&lt;FONT color=#000000&gt; t&lt;/FONT&gt;&lt;SPAN style="COLOR: gray"&gt;.&lt;/SPAN&gt;&lt;FONT color=#000000&gt;AmtDepositDate&lt;BR&gt;&lt;/FONT&gt;&lt;SPAN style="COLOR: blue"&gt;FROM&lt;BR&gt;&lt;/SPAN&gt;&lt;SPAN style="mso-tab-count: 1"&gt;&lt;FONT color=#000000&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/FONT&gt;&lt;/SPAN&gt;&lt;SPAN style="COLOR: gray"&gt;(&lt;BR&gt;&lt;/SPAN&gt;&lt;SPAN style="mso-tab-count: 1"&gt;&lt;FONT color=#000000&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/FONT&gt;&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;SELECT&lt;/SPAN&gt;&lt;FONT color=#000000&gt; &lt;BR&gt;&lt;SPAN style="mso-tab-count: 1"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;ID&lt;BR&gt;&lt;SPAN style="mso-tab-count: 1"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;/FONT&gt;&lt;SPAN style="COLOR: gray"&gt;,&lt;/SPAN&gt;&lt;FONT color=#000000&gt; Amt&lt;BR&gt;&lt;SPAN style="mso-tab-count: 1"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;/FONT&gt;&lt;SPAN style="COLOR: gray"&gt;,&lt;/SPAN&gt;&lt;FONT color=#000000&gt; AmtDepositDate&lt;BR&gt;&lt;SPAN style="mso-tab-count: 1"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;/FONT&gt;&lt;SPAN style="COLOR: gray"&gt;,&lt;/SPAN&gt;&lt;FONT color=#000000&gt; &lt;/FONT&gt;&lt;SPAN style="COLOR: fuchsia"&gt;row_number&lt;/SPAN&gt;&lt;SPAN style="COLOR: gray"&gt;()&lt;/SPAN&gt;&lt;FONT color=#000000&gt; &lt;/FONT&gt;&lt;SPAN style="COLOR: blue"&gt;over&lt;/SPAN&gt;&lt;FONT color=#000000&gt; &lt;/FONT&gt;&lt;SPAN style="COLOR: gray"&gt;(&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;partition&lt;/SPAN&gt;&lt;FONT color=#000000&gt; &lt;/FONT&gt;&lt;SPAN style="COLOR: blue"&gt;by&lt;/SPAN&gt;&lt;FONT color=#000000&gt; ID &lt;/FONT&gt;&lt;SPAN style="COLOR: blue"&gt;order&lt;/SPAN&gt;&lt;FONT color=#000000&gt; &lt;/FONT&gt;&lt;SPAN style="COLOR: blue"&gt;by&lt;/SPAN&gt;&lt;FONT color=#000000&gt; ID&lt;/FONT&gt;&lt;SPAN style="COLOR: gray"&gt;,&lt;/SPAN&gt;&lt;FONT color=#000000&gt; AmtDepositDate &lt;/FONT&gt;&lt;SPAN style="COLOR: blue"&gt;desc&lt;/SPAN&gt;&lt;SPAN style="COLOR: gray"&gt;)&lt;/SPAN&gt;&lt;FONT color=#000000&gt; &lt;/FONT&gt;&lt;SPAN style="COLOR: blue"&gt;as&lt;/SPAN&gt;&lt;FONT color=#000000&gt; rn &lt;BR&gt;&lt;SPAN style="mso-tab-count: 1"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;/FONT&gt;&lt;SPAN style="COLOR: blue"&gt;FROM&lt;/SPAN&gt;&lt;FONT color=#000000&gt; MoneyTable&lt;BR&gt;&lt;SPAN style="mso-tab-count: 1"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;/FONT&gt;&lt;SPAN style="COLOR: gray"&gt;)&lt;/SPAN&gt;&lt;FONT color=#000000&gt; t&lt;BR&gt;&lt;/FONT&gt;&lt;SPAN style="COLOR: blue"&gt;WHERE&lt;/SPAN&gt;&lt;FONT color=#000000&gt; rn&lt;/FONT&gt;&lt;SPAN style="COLOR: gray"&gt;=&lt;/SPAN&gt;&lt;FONT color=#000000&gt;1&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 5pt 0in; mso-layout-grid-align: none"&gt;&lt;SPAN style="FONT-SIZE: 10pt; COLOR: blue; FONT-FAMILY: 'Courier New'"&gt;SELECT&lt;/SPAN&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'"&gt;&lt;FONT color=#000000&gt; &lt;BR&gt;&lt;SPAN style="mso-tab-count: 1"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;MT2&lt;/FONT&gt;&lt;SPAN style="COLOR: gray"&gt;.&lt;/SPAN&gt;&lt;FONT color=#000000&gt;ID&lt;BR&gt;&lt;SPAN style="mso-tab-count: 1"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;/FONT&gt;&lt;SPAN style="COLOR: gray"&gt;,&lt;/SPAN&gt;&lt;FONT color=#000000&gt; MT2&lt;/FONT&gt;&lt;SPAN style="COLOR: gray"&gt;.&lt;/SPAN&gt;&lt;FONT color=#000000&gt;Name&lt;BR&gt;&lt;SPAN style="mso-tab-count: 1"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;/FONT&gt;&lt;SPAN style="COLOR: gray"&gt;,&lt;/SPAN&gt;&lt;FONT color=#000000&gt; MT2&lt;/FONT&gt;&lt;SPAN style="COLOR: gray"&gt;.&lt;/SPAN&gt;&lt;FONT color=#000000&gt;City&lt;BR&gt;&lt;/FONT&gt;&lt;SPAN style="COLOR: blue"&gt;FROM&lt;/SPAN&gt;&lt;FONT color=#000000&gt; &lt;BR&gt;&lt;SPAN style="mso-tab-count: 1"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;MyTable2 MT2&lt;BR&gt;&lt;/FONT&gt;&lt;SPAN style="COLOR: gray"&gt;LEFT&lt;/SPAN&gt;&lt;FONT color=#000000&gt; &lt;/FONT&gt;&lt;SPAN style="COLOR: gray"&gt;JOIN&lt;/SPAN&gt;&lt;FONT color=#000000&gt; @MyTable MT&lt;BR&gt;&lt;SPAN style="mso-tab-count: 1"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;/FONT&gt;&lt;SPAN style="COLOR: blue"&gt;ON&lt;/SPAN&gt;&lt;FONT color=#000000&gt; MT2&lt;/FONT&gt;&lt;SPAN style="COLOR: gray"&gt;.&lt;/SPAN&gt;&lt;FONT color=#000000&gt;ID &lt;/FONT&gt;&lt;SPAN style="COLOR: gray"&gt;=&lt;/SPAN&gt;&lt;FONT color=#000000&gt; MT&lt;/FONT&gt;&lt;SPAN style="COLOR: gray"&gt;.&lt;/SPAN&gt;&lt;FONT color=#000000&gt;ID&lt;BR&gt;&lt;/FONT&gt;&lt;SPAN style="COLOR: blue"&gt;WHERE&lt;/SPAN&gt;&lt;FONT color=#000000&gt; &lt;BR&gt;&lt;SPAN style="mso-tab-count: 1"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;c &lt;/FONT&gt;&lt;SPAN style="COLOR: gray"&gt;=&lt;/SPAN&gt;&lt;FONT color=#000000&gt; @SearchC &lt;/FONT&gt;&lt;SPAN style="COLOR: gray"&gt;AND&lt;/SPAN&gt;&lt;FONT color=#000000&gt; d &lt;/FONT&gt;&lt;SPAN style="COLOR: gray"&gt;=&lt;/SPAN&gt;&lt;FONT color=#000000&gt; @SearchD&lt;/FONT&gt;&lt;/SPAN&gt;&lt;SPAN style="FONT-SIZE: 12pt; COLOR: black; FONT-FAMILY: 'Times New Roman'"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;SPAN style="FONT-SIZE: 12pt; COLOR: black; FONT-FAMILY: 'Times New Roman'"&gt;Anyone experience similar or can offer up an reason for the optimization?&lt;/SPAN&gt;&lt;/P&gt;
&lt;P mce_keep="true"&gt;&amp;nbsp;&lt;/P&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=8787430" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/mab/archive/tags/SQL+Server/default.aspx">SQL Server</category></item><item><title>SQL Server 2005 UNPIVOT Command - changings columns to rows (normalizing)</title><link>http://blogs.msdn.com/mab/archive/2008/06/16/sql-server-2005-unpivot-command-changings-columns-to-rows-normalizing.aspx</link><pubDate>Tue, 17 Jun 2008 00:55:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:8608070</guid><dc:creator>mab</dc:creator><slash:comments>2</slash:comments><comments>http://blogs.msdn.com/mab/comments/8608070.aspx</comments><wfw:commentRss>http://blogs.msdn.com/mab/commentrss.aspx?PostID=8608070</wfw:commentRss><wfw:comment>http://blogs.msdn.com/mab/rsscomments.aspx?PostID=8608070</wfw:comment><description>&lt;P&gt;&lt;STRONG&gt;Scenario&lt;/STRONG&gt;&lt;BR&gt;A table that contains several columns that you need to take and change into rows in order to normalize the data.&amp;nbsp;&amp;nbsp; With SQL Server 2005, a new T-SQL command UNPIVOT can help.&amp;nbsp;&amp;nbsp; An example table:&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New"&gt;&lt;STRONG&gt;**Table called MyTable&lt;BR&gt;&lt;/STRONG&gt;FieldID FieldOne FieldTwo FieldThree&lt;BR&gt;1&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; abc&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;3.40&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;2008-03-03 00:00:00.000&lt;BR&gt;2&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;def&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;4.00&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 2008-01-02 00:00:00.000&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New"&gt;&lt;STRONG&gt;**Table Design&lt;/STRONG&gt;&lt;BR&gt;FieldID is an integer&lt;BR&gt;FieldOne is char(10) &lt;BR&gt;FieldTwo is decimal(14,2)&lt;BR&gt;FieldThree is a datetime&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New"&gt;&lt;/FONT&gt;&lt;FONT face="Courier New"&gt;&lt;STRONG&gt;Sample Code&lt;BR&gt;&lt;/STRONG&gt;&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;SELECT&lt;/FONT&gt;&lt;FONT size=2&gt; FieldId&lt;/FONT&gt;&lt;FONT color=#808080 size=2&gt;,&lt;/FONT&gt;&lt;FONT size=2&gt; FieldCode&lt;/FONT&gt;&lt;FONT color=#808080 size=2&gt;,&lt;/FONT&gt;&lt;FONT size=2&gt; FieldValue&lt;BR&gt;&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;FROM&lt;/FONT&gt;&lt;FONT size=2&gt; &lt;BR&gt;&lt;/FONT&gt;&lt;FONT color=#808080 size=2&gt;(&lt;BR&gt;&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;&amp;nbsp; SELECT&lt;/FONT&gt;&lt;FONT size=2&gt; FieldId&lt;/FONT&gt;&lt;FONT color=#808080 size=2&gt;,&lt;/FONT&gt;&lt;FONT size=2&gt; &lt;BR&gt;&lt;/FONT&gt;&lt;FONT color=#ff00ff size=2&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; CONVERT&lt;/FONT&gt;&lt;FONT color=#808080 size=2&gt;(&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;varchar&lt;/FONT&gt;&lt;FONT color=#808080 size=2&gt;(&lt;/FONT&gt;&lt;FONT size=2&gt;50&lt;/FONT&gt;&lt;FONT color=#808080 size=2&gt;),&lt;/FONT&gt;&lt;FONT size=2&gt; &lt;/FONT&gt;&lt;FONT color=#ff00ff size=2&gt;RTRIM&lt;/FONT&gt;&lt;FONT color=#808080 size=2&gt;(&lt;/FONT&gt;&lt;FONT size=2&gt;FieldOne &lt;/FONT&gt;&lt;FONT color=#808080 size=2&gt;))&lt;/FONT&gt;&lt;FONT size=2&gt; &lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;AS&lt;/FONT&gt;&lt;FONT size=2&gt; FieldOne&lt;/FONT&gt;&lt;FONT color=#808080 size=2&gt;,&lt;BR&gt;&lt;/FONT&gt;&lt;FONT color=#ff00ff size=2&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; CONVERT&lt;/FONT&gt;&lt;FONT color=#808080 size=2&gt;(&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;varchar&lt;/FONT&gt;&lt;FONT color=#808080 size=2&gt;(&lt;/FONT&gt;&lt;FONT size=2&gt;50&lt;/FONT&gt;&lt;FONT color=#808080 size=2&gt;),&lt;/FONT&gt;&lt;FONT size=2&gt; FieldTwo&lt;/FONT&gt;&lt;FONT color=#808080 size=2&gt;)&lt;/FONT&gt;&lt;FONT size=2&gt; &lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;AS&lt;/FONT&gt;&lt;FONT size=2&gt; FieldTwo&lt;/FONT&gt;&lt;FONT color=#808080 size=2&gt;,&lt;BR&gt;&lt;/FONT&gt;&lt;FONT color=#ff00ff size=2&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; CONVERT&lt;/FONT&gt;&lt;FONT color=#808080 size=2&gt;(&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;varchar&lt;/FONT&gt;&lt;FONT color=#808080 size=2&gt;(&lt;/FONT&gt;&lt;FONT size=2&gt;50&lt;/FONT&gt;&lt;FONT color=#808080 size=2&gt;),&lt;/FONT&gt;&lt;FONT size=2&gt; FieldThree&lt;/FONT&gt;&lt;FONT color=#808080 size=2&gt;)&lt;/FONT&gt;&lt;FONT size=2&gt; &lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;AS&lt;/FONT&gt;&lt;FONT size=2&gt; FieldThree&lt;BR&gt;&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;&amp;nbsp; FROM&lt;/FONT&gt;&lt;FONT size=2&gt; SampleUnpivot&lt;BR&gt;&lt;/FONT&gt;&lt;FONT color=#808080 size=2&gt;)&lt;/FONT&gt;&lt;FONT size=2&gt; MyTable&lt;BR&gt;&lt;/FONT&gt;&lt;FONT color=#808080 size=2&gt;UNPIVOT&lt;BR&gt;(&lt;/FONT&gt;&lt;FONT size=2&gt;FieldValue &lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;FOR&lt;/FONT&gt;&lt;FONT size=2&gt; FieldCode &lt;/FONT&gt;&lt;FONT color=#808080 size=2&gt;IN&lt;/FONT&gt;&lt;FONT size=2&gt; &lt;/FONT&gt;&lt;FONT color=#808080 size=2&gt;(&lt;/FONT&gt;&lt;FONT size=2&gt;FieldOne&lt;/FONT&gt;&lt;FONT color=#808080 size=2&gt;,&lt;/FONT&gt;&lt;FONT size=2&gt; FieldTwo&lt;/FONT&gt;&lt;FONT color=#808080 size=2&gt;,&lt;/FONT&gt;&lt;FONT size=2&gt; FieldThree&lt;/FONT&gt;&lt;FONT color=#808080 size=2&gt;))&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;AS&lt;/FONT&gt;&lt;FONT size=2&gt; MyUnPivot&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;Results&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New"&gt;FieldID FieldCode&amp;nbsp;&amp;nbsp;FieldValue&lt;BR&gt;1&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; FieldOne&amp;nbsp;&amp;nbsp; abc&lt;BR&gt;1&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; FieldTwo&amp;nbsp;&amp;nbsp; 3.40&lt;BR&gt;1&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; FieldThree&amp;nbsp;Mar&amp;nbsp; 3 2008 12:00AM&lt;BR&gt;2&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; FieldOne&amp;nbsp;&amp;nbsp; def&lt;BR&gt;2&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; FieldTwo&amp;nbsp;&amp;nbsp; 4.00&lt;BR&gt;2&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; FieldThree&amp;nbsp;Jan&amp;nbsp; 2 2008 12:00AM&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New"&gt;&lt;STRONG&gt;Notes&lt;/STRONG&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;&lt;FONT face="Courier New"&gt;If you have differnt data types make sure they are of the same time in the UNPIVOT IN clause&lt;/FONT&gt;&lt;/LI&gt;
&lt;LI&gt;&lt;FONT face="Courier New"&gt;Make sure to include the "ID" field (FieldID column in example above) to determine original record relationship&lt;/FONT&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;/FONT&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=8608070" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/mab/archive/tags/SQL+Server/default.aspx">SQL Server</category></item></channel></rss>