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

<channel>
	<title>Idea Excursion &#187; Microsoft</title>
	<atom:link href="http://www.ideaexcursion.com/category/microsoft/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.ideaexcursion.com</link>
	<description>Technology Musings</description>
	<lastBuildDate>Tue, 29 Jun 2010 21:24:52 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0</generator>
	<atom:link rel='hub' href='http://www.ideaexcursion.com/?pushpress=hub'/>
<creativeCommons:license>http://creativecommons.org/licenses/by-sa/3.0/us/</creativeCommons:license>		<item>
		<title>Cache multiple values in a Map Container for fast in-memory lookup</title>
		<link>http://www.ideaexcursion.com/2010/06/29/cache-multiple-values-in-a-map-container-for-fast-in-memory-lookup/</link>
		<comments>http://www.ideaexcursion.com/2010/06/29/cache-multiple-values-in-a-map-container-for-fast-in-memory-lookup/#comments</comments>
		<pubDate>Tue, 29 Jun 2010 21:24:15 +0000</pubDate>
		<dc:creator>Taylor Gerring</dc:creator>
				<category><![CDATA[Dynamics AX]]></category>
		<category><![CDATA[Dynamics AX 2009]]></category>
		<category><![CDATA[X++]]></category>

		<guid isPermaLink="false">http://www.ideaexcursion.com/?p=1517</guid>
		<description><![CDATA[Use this technique to reduce repeated trips to tables to lookup record details. Instead, cache the information once and reap speed benefits throughout your code]]></description>
			<content:encoded><![CDATA[<p>And thus begins my foray in to X++ development for Dynamics AX 2009. Here&#8217;s a proof of concept Job that I created to stuff multiple values into a Map using a Container. This allows me to lookup a few customer details without repeatedly making trips back to CustTable.</p>

<div class="wp_syntax"><div class="code"><pre class="xpp" style="font-family:monospace;"><span style="color: #0000ff;">static</span> <span style="color: #0000ff;">void</span> MapContainerTest<span style="color: #000000;">&#40;</span>Args _args<span style="color: #000000;">&#41;</span>
<span style="color: #000000;">&#123;</span>
    Map                     custNotesMap;
    <span style="color: #0000ff;">Container</span>               custContainer;
    CustTable               custTable;
    SalesSourceSystemId     admarcSystemId <span style="color: #00007f;">=</span> <span style="color: #ff0000;">&quot;DPRADM&quot;</span>;
    <span style="color: #0000ff;">Container</span>               conCustDetails;
        <span style="color: #0000ff;">str</span>                     admarcAccountId <span style="color: #00007f;">=</span> <span style="color: #ff0000;">&quot;000123456&quot;</span>;
    ;
&nbsp;
    custNotesMap <span style="color: #00007f;">=</span> <span style="color: #0000ff;">new</span> Map<span style="color: #000000;">&#40;</span>Types<span style="color: #00007f;">::</span><span style="color: #000000;">String</span><span style="color: #00007f;">,</span> Types<span style="color: #00007f;">::</span><span style="color: #0000ff;">Container</span><span style="color: #000000;">&#41;</span>;
    <span style="color: #0000ff;">while</span> <span style="color: #0000ff;">select</span> AdmarcAccountId<span style="color: #00007f;">,</span> RecId<span style="color: #00007f;">,</span> TableId<span style="color: #00007f;">,</span> dataAreaId<span style="color: #00007f;">,</span> PartyId <span style="color: #0000ff;">from</span> custTable <span style="color: #0000ff;">where</span> custTable.<span style="color: #000000;">AdmarcSystemId</span> <span style="color: #00007f;">==</span> admarcSystemId
    <span style="color: #000000;">&#123;</span>
        custContainer <span style="color: #00007f;">=</span> <span style="color: #0000ff;">conNull</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>;
        custContainer <span style="color: #00007f;">=</span> <span style="color: #000000;">&#91;</span>custTable.<span style="color: #000000;">RecId</span><span style="color: #00007f;">,</span> custTable.<span style="color: #000000;">TableId</span><span style="color: #00007f;">,</span> custTable.<span style="color: #000000;">dataAreaId</span><span style="color: #00007f;">,</span> custTable.<span style="color: #000000;">PartyId</span><span style="color: #000000;">&#93;</span>;
&nbsp;
        custNotesMap.<span style="color: #000000;">insert</span><span style="color: #000000;">&#40;</span>custTable.<span style="color: #000000;">AdmarcAccountId</span><span style="color: #00007f;">,</span> custContainer<span style="color: #000000;">&#41;</span>;
    <span style="color: #000000;">&#125;</span>
&nbsp;
    <span style="color: #0000ff;">if</span> <span style="color: #000000;">&#40;</span>custNotesMap.<span style="color: #0000ff;">exists</span><span style="color: #000000;">&#40;</span>admarcAccountId<span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span>
        conCustDetails <span style="color: #00007f;">=</span> custNotesMap.<span style="color: #000000;">lookup</span><span style="color: #000000;">&#40;</span>admarcAccountId<span style="color: #000000;">&#41;</span>;
    <span style="color: #0000ff;">else</span>
        error<span style="color: #000000;">&#40;</span><span style="color: #ff0000;">&quot;Customer not found.&quot;</span><span style="color: #000000;">&#41;</span>;
&nbsp;
    info<span style="color: #000000;">&#40;</span><span style="color: #0000ff;">strfmt</span><span style="color: #000000;">&#40;</span><span style="color: #ff0000;">&quot;RecId: %1&quot;</span><span style="color: #00007f;">,</span> <span style="color: #0000ff;">conpeek</span><span style="color: #000000;">&#40;</span>conCustDetails<span style="color: #00007f;">,</span> <span style="color: #000000;">1</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span>;
    info<span style="color: #000000;">&#40;</span><span style="color: #0000ff;">strfmt</span><span style="color: #000000;">&#40;</span><span style="color: #ff0000;">&quot;TableId: %1&quot;</span><span style="color: #00007f;">,</span> <span style="color: #0000ff;">conpeek</span><span style="color: #000000;">&#40;</span>conCustDetails<span style="color: #00007f;">,</span> <span style="color: #000000;">2</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span>;
    info<span style="color: #000000;">&#40;</span><span style="color: #0000ff;">strfmt</span><span style="color: #000000;">&#40;</span><span style="color: #ff0000;">&quot;dataAreaId: %1&quot;</span><span style="color: #00007f;">,</span> <span style="color: #0000ff;">conpeek</span><span style="color: #000000;">&#40;</span>conCustDetails<span style="color: #00007f;">,</span> <span style="color: #000000;">3</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span>;
    info<span style="color: #000000;">&#40;</span><span style="color: #0000ff;">strfmt</span><span style="color: #000000;">&#40;</span><span style="color: #ff0000;">&quot;PartyId: %1&quot;</span><span style="color: #00007f;">,</span> <span style="color: #0000ff;">conpeek</span><span style="color: #000000;">&#40;</span>conCustDetails<span style="color: #00007f;">,</span> <span style="color: #000000;">4</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span>;
<span style="color: #000000;">&#125;</span></pre></div></div>

<p>In fact, it&#8217;s pretty fast and I&#8217;m using similar caching technique all over the place to speed up large jobs.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.ideaexcursion.com/2010/06/29/cache-multiple-values-in-a-map-container-for-fast-in-memory-lookup/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Default column value to identity of different column</title>
		<link>http://www.ideaexcursion.com/2010/04/19/default-column-value-to-identity-of-different-column/</link>
		<comments>http://www.ideaexcursion.com/2010/04/19/default-column-value-to-identity-of-different-column/#comments</comments>
		<pubDate>Mon, 19 Apr 2010 21:09:36 +0000</pubDate>
		<dc:creator>Taylor Gerring</dc:creator>
				<category><![CDATA[SQL Server]]></category>

		<guid isPermaLink="false">http://www.ideaexcursion.com/?p=1507</guid>
		<description><![CDATA[Given a table with one column as an identity, how you default another column to the identity of the first, while retaining the ability to change later]]></description>
			<content:encoded><![CDATA[<p>Thanks to my friend Paul Mayle for putting this one out there:</p>
<blockquote><p>Given a table with columns:<br />
A: int, primary key, identity<br />
B: int, not null</p>
<p>How can I set a default for column B to be the value in column A?</p></blockquote>
<p>This is an interesting problem on a couple levels. First, a computed column won&#8217;t work, because we need the ability to arbitrarily update column B. We could program a trigger, but I prefer to avoid them when possible. Preferably, we could actualize the purpose of the DEFAULT option. Unfortunately, this isn&#8217;t immediately an apparent choice because SQL Server doesn&#8217;t allow you to reference a column in a DEFAULT specification. In fact, according to <abbr title="Books Online">BOL</abbr>, &#8220;Only a constant value, such as a character string; a scalar function (either a  system, user-defined, or CLR function); or NULL can be used as a default.&#8221;<br />
<span id="more-1507"></span><br />
Fortunately, the column which we&#8217;re trying to set a default from had an identity property, and system functions dealing with identity values is the key to using the DEFAULT specification. First, a little code:</p>

<div class="wp_syntax"><div class="code"><pre class="tsql" style="font-family:monospace;"><span style="color: #0000FF;">CREATE</span> <span style="color: #0000FF;">TABLE</span> dbo.<span style="color: #202020;">IdentDefault</span>
<span style="color: #808080;">&#40;</span>
	A <span style="color: #0000FF;">INT</span> <span style="color: #808080;">NOT</span> <span style="color: #808080;">NULL</span> <span style="color: #0000FF;">IDENTITY</span> <span style="color: #808080;">&#40;</span><span style="color: #000;">1</span>, <span style="color: #000;">1</span><span style="color: #808080;">&#41;</span> <span style="color: #0000FF;">PRIMARY</span> <span style="color: #0000FF;">KEY</span>,
	B <span style="color: #0000FF;">INT</span> <span style="color: #808080;">NOT</span> <span style="color: #808080;">NULL</span> <span style="color: #0000FF;">DEFAULT</span> <span style="color: #FF00FF;">SCOPE_IDENTITY</span><span style="color: #808080;">&#40;</span><span style="color: #808080;">&#41;</span>
<span style="color: #808080;">&#41;</span>
&nbsp;
<span style="color: #0000FF;">INSERT</span> <span style="color: #0000FF;">INTO</span> dbo.<span style="color: #202020;">IdentDefault</span> <span style="color: #0000FF;">DEFAULT</span> <span style="color: #0000FF;">VALUES</span>
<span style="color: #0000FF;">INSERT</span> <span style="color: #0000FF;">INTO</span> dbo.<span style="color: #202020;">IdentDefault</span> <span style="color: #0000FF;">DEFAULT</span> <span style="color: #0000FF;">VALUES</span>
<span style="color: #0000FF;">INSERT</span> <span style="color: #0000FF;">INTO</span> dbo.<span style="color: #202020;">IdentDefault</span> <span style="color: #0000FF;">DEFAULT</span> <span style="color: #0000FF;">VALUES</span>
&nbsp;
<span style="color: #0000FF;">UPDATE</span> dbo.<span style="color: #202020;">IdentDefault</span> <span style="color: #0000FF;">SET</span> B <span style="color: #808080;">=</span> <span style="color: #000;">10</span> <span style="color: #0000FF;">WHERE</span> A <span style="color: #808080;">=</span> <span style="color: #000;">1</span>
&nbsp;
<span style="color: #0000FF;">SELECT</span> <span style="color: #808080;">*</span> <span style="color: #0000FF;">FROM</span> dbo.<span style="color: #202020;">IdentDefault</span></pre></div></div>

<p>And the result:</p>

<div class="wp_syntax"><div class="code"><pre class="none" style="font-family:monospace;">A           B
----------- -----------
1           10
2           2
3           3</pre></div></div>

<p>As you can see from the above result set, column B defaults to whatever column A contains, yet we can still update column B to whatever value necessary.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.ideaexcursion.com/2010/04/19/default-column-value-to-identity-of-different-column/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Import Excel 2007 with SQL Server Import and Export Wizard</title>
		<link>http://www.ideaexcursion.com/2010/01/06/import-excel-2007-with-sql-server-import-and-export-wizard/</link>
		<comments>http://www.ideaexcursion.com/2010/01/06/import-excel-2007-with-sql-server-import-and-export-wizard/#comments</comments>
		<pubDate>Wed, 06 Jan 2010 15:38:02 +0000</pubDate>
		<dc:creator>Taylor Gerring</dc:creator>
				<category><![CDATA[SQL Server]]></category>

		<guid isPermaLink="false">http://www.ideaexcursion.com/?p=1466</guid>
		<description><![CDATA[Neither SQL Server 2008 nor Office 2007 install Microsoft.ACE.OLEDB.12.0 providers. With a small tweak, we can enable connections to Excel and Access 2007.]]></description>
			<content:encoded><![CDATA[<p>If you need to pull in data from an external source ad hoc, using <abbr title="SQL Server Integration Services">SSIS</abbr> is often overkill. Instead, SQL Server Import and Export Wizard (called &#8220;Import and Export Data&#8221; in the Start Menu, but DTSWizard.exe in the filesystem) usually does a good job. This is especially great way to pull in data from users, which typically comes in the form of an Excel attachment. Unfortunately, the providers to import from the newer Office 2007 and 2010 XLSX  file format (also referred to as &#8220;Open Office XML&#8221;) are not available by default and will likely result in a &#8220;Microsoft.ACE.OLEDB.12.0 Provider is not registered&#8221; error. The fix is as easy as  installing the &#8220;<a title="Download Details: 2007 Office System Driver: Data Connectivity Components" href="http://www.microsoft.com/downloads/details.aspx?FamilyID=7554F536-8C28-4598-9B72-EF94E038C891&amp;displaylang=en" target="_blank">2007 Office System Driver: Data Connectivity Components</a>&#8221; package from Microsoft. This same package will also enable access to Access 2007.<br />
<span id="more-1466"></span><br />
After installation, simply re-run DTSWizard and try to import again. If you can&#8217;t find Excel or Access in the Data Source dropdown list, remember that the providers only work in 32-bit mode, and therefore you need to run &#8220;Import and Export Data (32-bit),&#8221; which is located at &#8220;C:\Program Files (x86)\Microsoft SQL Server\100\DTS\Binn\DTSWizard.exe&#8221;.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.ideaexcursion.com/2010/01/06/import-excel-2007-with-sql-server-import-and-export-wizard/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Microsoft Office 2010 Beta posted on MSDN/TechNet</title>
		<link>http://www.ideaexcursion.com/2009/11/16/microsoft-office-2010-beta-posted-on-msdntechnet/</link>
		<comments>http://www.ideaexcursion.com/2009/11/16/microsoft-office-2010-beta-posted-on-msdntechnet/#comments</comments>
		<pubDate>Mon, 16 Nov 2009 20:12:01 +0000</pubDate>
		<dc:creator>Taylor Gerring</dc:creator>
				<category><![CDATA[Microsoft]]></category>
		<category><![CDATA[Office]]></category>

		<guid isPermaLink="false">http://www.ideaexcursion.com/?p=1450</guid>
		<description><![CDATA[The new Office 2010 Beta just dropped on MSDN and TechNet. The package is available in both 64-bit and 32-bit flavors; download details for both appear below.]]></description>
			<content:encoded><![CDATA[<p>The new Office 2010 Beta was expected this week and just dropped on MSDN and TechNet. Unfortunately, it does appear to be on the faster &#8220;Top Downloads&#8221; servers &#8211; I&#8217;m getting a paltry 450KB/s. The Professional Plus 2010 package is available in both 64-bit and 32-bit flavors; download details for both appear below.<br />
<span id="more-1450"></span></p>
<ul>
<li>File Name: en_office_professional_plus_2010_beta_x64_x16-19234.exe</li>
<li>Size: 749.87 (MB)</li>
<li> Date Posted (UTC): 11/16/2009 7:21:24 AM</li>
<li> ISO/CRC: D5C14D40</li>
<li> SHA1: D07BC0DEE307E05F955CE44825F85084B94595B8</li>
</ul>
<ul>
<li> File Name: en_office_professional_plus_2010_beta_x86_x16-19227.exe</li>
<li>Size: 684.48 (MB)</li>
<li> Date Posted (UTC): 11/16/2009 7:21:23 AM</li>
<li>ISO/CRC: D3ACD2EF</li>
<li>SHA1: F219E1D7FE830DCD6A796FAFEA3A5D0D4662EE89</li>
</ul>
<p>(via <a title="Microsoft Office 2010 beta available on MSDN/TechNet" href="http://www.neowin.net/news/main/09/11/16/microsoft-office-2010-beta-available-on-msdntechnet" target="_blank">Neowin</a>)</p>
]]></content:encoded>
			<wfw:commentRss>http://www.ideaexcursion.com/2009/11/16/microsoft-office-2010-beta-posted-on-msdntechnet/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Accessing Custom .NET Assemblies in SSIS 2008 Script Tasks</title>
		<link>http://www.ideaexcursion.com/2009/10/14/accessing-custom-net-assemblies-in-ssis-2008-script-tasks/</link>
		<comments>http://www.ideaexcursion.com/2009/10/14/accessing-custom-net-assemblies-in-ssis-2008-script-tasks/#comments</comments>
		<pubDate>Wed, 14 Oct 2009 19:36:24 +0000</pubDate>
		<dc:creator>Taylor Gerring</dc:creator>
				<category><![CDATA[SSIS]]></category>
		<category><![CDATA[.NET]]></category>
		<category><![CDATA[C#]]></category>
		<category><![CDATA[SQL Server]]></category>
		<category><![CDATA[VB.NET]]></category>

		<guid isPermaLink="false">http://www.ideaexcursion.com/?p=1429</guid>
		<description><![CDATA[If you need to access a custom .NET Assembly from an SSIS Script Task, Microsoft doesn't make things very easy - but it's still possible with a little setup.]]></description>
			<content:encoded><![CDATA[<p>If you need to access a custom .NET Assembly from an <abbr title="SQL Server Integration Services">SSIS</abbr> Script Task, Microsoft doesn&#8217;t make things very easy &#8211; but it&#8217;s still possible with a little setup. This is a great way to introduce custom data types or some new functionality without having to replicate that code in a new environment.<br />
<span id="more-1429"></span></p>
<h2>The Setup</h2>
<ul>
<li>Windows 7 64-bit</li>
<li>Visual Studio 2008</li>
<li>SQL Server 2008 64-bit</li>
</ul>
<h2>The Process</h2>
<ol>
<li>Create a signing key (See also, <a title="How to: Create a Public/Private Key Pair" href="http://msdn.microsoft.com/en-us/library/6f05ezxy.aspx " target="_blank">How to: Create a Public/Private Key Pair</a>)
<ol>
<li>Open Visual Studio 2008 command Prompt &#8211; the regular command prompt <em>will not</em> work</li>
<li>Change to a friendly directory: cd %userprofile%\Desktop</li>
<li>Create the key file: sn -k key.snk</li>
</ol>
</li>
<li>Sign the assembly &#8211; There are a few ways to do this, but I found this to be the easiest. If you want to sign it some other way, check out <a title="http://msdn.microsoft.com/en-us/library/xc31ft41.aspx" href="http://msdn.microsoft.com/en-us/library/xc31ft41.aspx" target="_blank">How to: Sign an Assembly with a Strong Name</a>
<ol>
<li>Right-click the Project</li>
<li>Select &#8220;Properties&#8221;</li>
<li>Navigate to the &#8220;Signing&#8221; tab</li>
<li>Browse to strong name key file (which was created in the previous step)</li>
<li>Recompile the project</li>
</ol>
</li>
<li>Copy the re-compiled assembly to your <acronym title="Global Assembly Cache">GAC</acronym>
<ol>
<li>gacutil -i &#8220;C:\Path\to\CustomAssemblyName.dll&#8221;</li>
</ol>
</li>
<li>Copy assembly to &#8220;%programfiles(x86)%\Microsoft SQL Server\100\SDK\Assemblies&#8221;</li>
<li>Add reference in script task. Repeat this for <strong>every </strong>Script Task you want to access this assembly from
<ol>
<li>Right-click References</li>
<li>Click &#8220;Add Reference&#8230;&#8221;
<p><div id="attachment_1437" class="wp-caption alignnone" style="width: 310px"><a rel="attachment wp-att-1437" href="http://www.ideaexcursion.com/2009/10/14/accessing-custom-net-assemblies-in-ssis-2008-script-tasks/add-reference/"><img class="size-medium wp-image-1437" title="Add Reference..." src="http://www.ideaexcursion.com/wp-content/uploads/2009/10/add-reference-300x139.png" alt="Add Reference..." width="300" height="139" /></a><p class="wp-caption-text">Add Reference...</p></div></li>
<li>On the .NET tab, scroll to find your assembly</li>
<li>Press &#8220;OK&#8221;</li>
<li>The Assembly should now appear under the References list</li>
</ol>
</li>
<li> Add a reference to the assembly in code, at the top
<ol>
<li>(C#) Using CustomAssemblyName;</li>
<li> (VB.NET) Imports CustomAssemblyName</li>
</ol>
</li>
<li>You should now have full access to the imported <abbr title="Dynamic Link Library">DLL</abbr></li>
</ol>
<h2>Caveats</h2>
<p>This method works pretty well, but deployment isn&#8217;t exactly seamless &#8211; you&#8217;ll have to repeat this for each server and re-register &amp; copy the <abbr title="Dynamic Link Library">DLL</abbr> separately for any updates. Additionally, there is no way to globally add the assembly reference to the entire project or package. Instead, you&#8217;ll have to repeat step 6 (adding the reference) for every Script Task.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.ideaexcursion.com/2009/10/14/accessing-custom-net-assemblies-in-ssis-2008-script-tasks/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>SQL Server Regular Expression CLR UDF</title>
		<link>http://www.ideaexcursion.com/2009/08/18/sql-server-regular-expression-clr-udf/</link>
		<comments>http://www.ideaexcursion.com/2009/08/18/sql-server-regular-expression-clr-udf/#comments</comments>
		<pubDate>Tue, 18 Aug 2009 19:55:21 +0000</pubDate>
		<dc:creator>Taylor Gerring</dc:creator>
				<category><![CDATA[SQL Server]]></category>
		<category><![CDATA[CLR]]></category>
		<category><![CDATA[RegEx]]></category>
		<category><![CDATA[Regular Expressions]]></category>
		<category><![CDATA[SQL Server 2005]]></category>
		<category><![CDATA[SQL Server 2008]]></category>
		<category><![CDATA[UDF]]></category>

		<guid isPermaLink="false">http://www.ideaexcursion.com/?p=1378</guid>
		<description><![CDATA[How to create a .NET user-defined function that exposes RegEx functionality to Microsoft SQL Server.]]></description>
			<content:encoded><![CDATA[<p>Face it: data cleanup is a fact of life. While SQL Server has a handful of string manipulation functions, nothing even comes close to the power of RegEx. Fortunately, by leveraging the <abbr title="Common Language Runtime">CLR</abbr> functionality in SQL Server 2005 and SQL Server 2008, we can add a host of new features, including regular expressions.<br />
<span id="more-1378"></span></p>
<h3>Steps</h3>
<ol>
<li>First, fire up Visual Studio (2005 or 2008 &#8211; it doesn&#8217;t matter).</li>
<li>Create a new project &#8211; name it something clever, like &#8220;RegEx&#8221;</li>
<li>After creating the project, you should be prompted to connect to a database where you&#8217;ll eventually want to deploy the project. This is completely optional and can be changed later.</li>
<li>Right-click the project name (&#8220;RegEx&#8221;) and choose Add &rarr; User-Defined Function<div id="attachment_1389" class="wp-caption alignnone" style="width: 310px"><a href="http://www.ideaexcursion.com/2009/08/18/sql-server-regular-expression-clr-udf/add-udf/" rel="attachment wp-att-1389"><img src="http://www.ideaexcursion.com/wp-content/uploads/2009/08/add-udf-300x202.PNG" alt="Add User Defined Function" title="Add User Defined Function" width="300" height="202" class="size-medium wp-image-1389" /></a><p class="wp-caption-text">Add User Defined Function</p></div></li>
<li>Name the file RegExMatch.</li>
<li>Paste the following code into that file</li>
<li>When done, simple build (Ctrl+Shift+B) and deploy (Right-click the project name (&#8220;RegEx&#8221;) &rarr; Deploy).</li>
</ol>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
</pre></td><td class="code"><pre class="csharp" style="font-family:monospace;"><span style="color: #0600FF;">using</span> <span style="color: #008080;">System</span><span style="color: #008000;">;</span>
<span style="color: #0600FF;">using</span> <span style="color: #008080;">System.Data</span><span style="color: #008000;">;</span>
<span style="color: #0600FF;">using</span> <span style="color: #008080;">System.Data.SqlClient</span><span style="color: #008000;">;</span>
<span style="color: #0600FF;">using</span> <span style="color: #008080;">System.Data.SqlTypes</span><span style="color: #008000;">;</span>
<span style="color: #0600FF;">using</span> <span style="color: #008080;">Microsoft.SqlServer.Server</span><span style="color: #008000;">;</span>
<span style="color: #0600FF;">using</span> <span style="color: #008080;">System.Text.RegularExpressions</span><span style="color: #008000;">;</span>
&nbsp;
<span style="color: #0600FF;">public</span> <span style="color: #0600FF;">partial</span> <span style="color: #FF0000;">class</span> UserDefinedFunctions
<span style="color: #000000;">&#123;</span>
    <span style="color: #000000;">&#91;</span>Microsoft.<span style="color: #0000FF;">SqlServer</span>.<span style="color: #0000FF;">Server</span>.<span style="color: #0000FF;">SqlFunction</span><span style="color: #000000;">&#40;</span>IsDeterministic <span style="color: #008000;">=</span> <span style="color: #0600FF;">true</span>, IsPrecise <span style="color: #008000;">=</span> <span style="color: #0600FF;">true</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#93;</span>
    <span style="color: #0600FF;">public</span> <span style="color: #0600FF;">static</span> SqlString RegExMatch<span style="color: #000000;">&#40;</span>SqlString expression, SqlString pattern<span style="color: #000000;">&#41;</span>
    <span style="color: #000000;">&#123;</span>
        <span style="color: #0600FF;">if</span> <span style="color: #000000;">&#40;</span>expression.<span style="color: #0000FF;">IsNull</span> <span style="color: #008000;">||</span> pattern.<span style="color: #0000FF;">IsNull</span><span style="color: #000000;">&#41;</span>
            <span style="color: #0600FF;">return</span> SqlString.<span style="color: #0000FF;">Null</span><span style="color: #008000;">;</span>
&nbsp;
        Match match <span style="color: #008000;">=</span> <span style="color: #008000;">new</span> Regex<span style="color: #000000;">&#40;</span>pattern.<span style="color: #0000FF;">ToString</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span>.<span style="color: #0000FF;">Match</span><span style="color: #000000;">&#40;</span>expression.<span style="color: #0000FF;">ToString</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span><span style="color: #008000;">;</span>
&nbsp;
        <span style="color: #0600FF;">return</span> match.<span style="color: #0000FF;">Success</span> <span style="color: #008000;">?</span> <span style="color: #008000;">new</span> SqlString<span style="color: #000000;">&#40;</span>match.<span style="color: #0000FF;">Value</span><span style="color: #000000;">&#41;</span> <span style="color: #008000;">:</span> SqlString.<span style="color: #0000FF;">Null</span><span style="color: #008000;">;</span>
&nbsp;
    <span style="color: #000000;">&#125;</span>
<span style="color: #000000;">&#125;</span><span style="color: #008000;">;</span></pre></td></tr></table></div>

<h3>Code Explanation</h3>
<ul>
<li>Line 1-6: Including necessary assemblies. The only item you need to add is line 6 &#8211; System.Text.RegularExpressions</li>
<li>Line 11: We indicate the function requires 2 parameters, the input string and the regular expression to apply.</li>
<li>Line 13-14: Check if either input string is NULL. If so, return NULL and do nothing else.</li>
<li>Line 16: There&#8217;s a lot packed on this line, but essentially, it creates an object named <em>match</em> based on the results of the regular expression match operation.</li>
<li>Line 18: Use the ternary operator to check if the match was a success. If so, return the matching string. Otherwise, return a NULL.</li>
</ul>
<h3>Examples</h3>
<p>We&#8217;re going to use a simple regular expression to check for a valid US postal code (AKA Zipcode + 4):</p>
<pre>^\d{5}(-\d{4})?$</pre>
<p>This regular expressions checks for exactly 5 digits followed by an option group of hyphen and 4 more digits.</p>

<div class="wp_syntax"><div class="code"><pre class="tsql" style="font-family:monospace;"><span style="color: #0000FF;">SELECT</span>
	  dbo.<span style="color: #202020;">RegExMatch</span><span style="color: #808080;">&#40;</span><span style="color: #FF0000;">'90210'</span>,<span style="color: #FF0000;">'^<span style="color: #000099; font-weight: bold;">\d</span>{5}(-<span style="color: #000099; font-weight: bold;">\d</span>{4})?$'</span><span style="color: #808080;">&#41;</span>
	, dbo.<span style="color: #202020;">RegExMatch</span><span style="color: #808080;">&#40;</span><span style="color: #FF0000;">'90210-1234'</span>,<span style="color: #FF0000;">'^<span style="color: #000099; font-weight: bold;">\d</span>{5}(-<span style="color: #000099; font-weight: bold;">\d</span>{4})?$'</span><span style="color: #808080;">&#41;</span>
	, dbo.<span style="color: #202020;">RegExMatch</span><span style="color: #808080;">&#40;</span><span style="color: #FF0000;">'90210-'</span>,<span style="color: #FF0000;">'^<span style="color: #000099; font-weight: bold;">\d</span>{5}(-<span style="color: #000099; font-weight: bold;">\d</span>{4})?$'</span><span style="color: #808080;">&#41;</span>
	, dbo.<span style="color: #202020;">RegExMatch</span><span style="color: #808080;">&#40;</span><span style="color: #FF0000;">'9021A'</span>,<span style="color: #FF0000;">'^<span style="color: #000099; font-weight: bold;">\d</span>{5}(-<span style="color: #000099; font-weight: bold;">\d</span>{4})?$'</span><span style="color: #808080;">&#41;</span></pre></div></div>

<p>And results:</p>

<div class="wp_syntax"><div class="code"><pre class="none" style="font-family:monospace;">90210	90210-1234	NULL	NULL</pre></div></div>

<h3>Other notes</h3>
<p>If you need to change the target database, do so in the project&#8217;s properties:</p>
<ol>
<li>Right-click the proeject name (&#8220;RegEx&#8221;) &rarr; Properties</li>
<li>Select the Database tab (2nd item from the bottom)</li>
<li>Click &#8220;Browse&#8230;&#8221; to create and test the connection string.<div id="attachment_1390" class="wp-caption alignnone" style="width: 310px"><a href="http://www.ideaexcursion.com/2009/08/18/sql-server-regular-expression-clr-udf/database-properties/" rel="attachment wp-att-1390"><img src="http://www.ideaexcursion.com/wp-content/uploads/2009/08/database-properties-300x148.PNG" alt="Database Properties" title="Database Properties" width="300" height="148" class="size-medium wp-image-1390" /></a><p class="wp-caption-text">Database Properties</p></div></li>
</ol>
<p>Thanks to <a title="Regular Expression Replace in SQL 2005 (via the CLR)" href="http://weblogs.sqlteam.com/jeffs/archive/2007/04/27/SQL-2005-Regular-Expression-Replace.aspx" target="_blank">Jeff&#8217;s SQL Server Blog</a> for the initial Regular Expression Replace code.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.ideaexcursion.com/2009/08/18/sql-server-regular-expression-clr-udf/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Windows 7 RTM download details</title>
		<link>http://www.ideaexcursion.com/2009/08/06/windows-7-rtm-download-details/</link>
		<comments>http://www.ideaexcursion.com/2009/08/06/windows-7-rtm-download-details/#comments</comments>
		<pubDate>Thu, 06 Aug 2009 19:01:17 +0000</pubDate>
		<dc:creator>Taylor Gerring</dc:creator>
				<category><![CDATA[Windows]]></category>
		<category><![CDATA[win7]]></category>
		<category><![CDATA[Windows 7]]></category>

		<guid isPermaLink="false">http://www.ideaexcursion.com/?p=1367</guid>
		<description><![CDATA[Full download details - including SHA1 hashes - for x64 and x86 editions of Windows 7 Ultimate, Enterprise, Professional, Home Premium, Home Basic, and Starter]]></description>
			<content:encoded><![CDATA[<p>The time has finally arrived! Windows 7, the latest Operating System from Microsoft went <abbr title="Release To Manufacturing">RTM</abbr> not long ago and DVD images were finally posted on <abbr title="MicroSoft Developer Network">MSDN</abbr> and TechNet. In addition to filenames, SHA1 hashes and sizes are posted.</p>
<p>You can, of course download the images through the normal <abbr title="MicroSoft Developer Network">MSDN</abbr>  channels, but speed is limited to about 30KB/sec due to demand. Fortunately, <a title="MSDN Subscriptions | Top Downloads" href="http://msdn.microsoft.com/en-us/subscriptions/bb608344.aspx" target="_blank"><abbr title="MicroSoft Developer Network">MSDN</abbr>  Top Downloads</a> also hosts the images through Akamai and I&#8217;m getting 1-1.5MB/sec from here.</p>
<p>Here&#8217;s a list of everything that&#8217;s available:<br />
<span id="more-1367"></span></p>
<ul>
<li>Windows 7 Ultimate (x64) &#8211; DVD (English)
<ul>
<li>File Name: en_windows_7_ultimate_x64_dvd_x15-65922.iso</li>
<li>Date Posted (UTC): 8/6/2009 9:59:54 AM</li>
<li>SHA1: 326327CC2FF9F05379F5058C41BE6BC5E004BAA7</li>
<li>ISO/CRC: 1F1257CA</li>
<li>Size: 3,075.30 (MB)</li>
</ul>
</li>
<li>Windows 7 Ultimate (x86) &#8211; DVD (English)
<ul>
<li>File Name: en_windows_7_ultimate_x86_dvd_x15-65921.iso</li>
<li>Date Posted (UTC): 8/6/2009 9:59:54 AM</li>
<li>SHA1: 5395DC4B38F7BDB1E005FF414DEEDFDB16DBF610</li>
<li>ISO/CRC: C1C20F76</li>
<li>Size: 2,385.99 (MB)</li>
</ul>
</li>
<li>Windows 7 Enterprise (x64) &#8211; DVD (English)
<ul>
<li>File Name: en_windows_7_enterprise_x64_dvd_x15-70749.iso</li>
<li>Date Posted (UTC): 8/6/2009 9:59:54 AM</li>
<li>SHA1: A89DCE706D527206CB464EF86ACD3A3D13A332DB</li>
<li>ISO/CRC: D4597619</li>
<li>Size: 2,976.62 (MB)</li>
</ul>
</li>
<li>Windows 7 Enterprise (x86) &#8211; DVD (English)
<ul>
<li>File Name: en_windows_7_enterprise_x86_dvd_x15-70745.iso</li>
<li>Date Posted (UTC): 8/6/2009 9:59:54 AM</li>
<li>SHA1: C6B905E48FDB6CB5BFCA967715A64461B812D40C</li>
<li>ISO/CRC: 6A9B5097</li>
<li>Size: 2,289.20 (MB)</li>
</ul>
</li>
<li>Windows 7 Professional (x64) &#8211; DVD (English)
<ul>
<li>File Name: en_windows_7_professional_x64_dvd_x15-65805.iso</li>
<li>Date Posted (UTC): 8/6/2009 9:59:54 AM</li>
<li>SHA1: 50127304441A793EE51B3F501289F6599A559E9F</li>
<li>ISO/CRC: 502C42C1</li>
<li>Size: 3,075.30 (MB)</li>
</ul>
</li>
<li>Windows 7 Professional (x86) &#8211; DVD (English)
<ul>
<li>File Name: en_windows_7_professional_x86_dvd_x15-65804.iso</li>
<li>Date Posted (UTC): 8/6/2009 9:59:54 AM</li>
<li>SHA1: 697FA06554502FB21D30275273B25747299C020D</li>
<li>ISO/CRC: 578725D1</li>
<li>Size: 2,385.99 (MB)</li>
</ul>
</li>
<li>Windows 7 Home Premium (x64) &#8211; DVD (English)
<ul>
<li>File Name: en_windows_7_home_premium_x64_dvd_x15-65733.iso</li>
<li>Date Posted (UTC): 8/6/2009 9:59:54 AM</li>
<li>SHA1: 336779EA6B65F63E11A609B4D021439C47AB315B</li>
<li>ISO/CRC: 56D954E4</li>
<li>3,075.30 (MB)</li>
</ul>
</li>
<li>Windows 7 Home Premium (x86) &#8211; DVD (English)
<ul>
<li>File Name: en_windows_7_home_premium_x86_dvd_x15-65732.iso</li>
<li>Date Posted (UTC): 8/6/2009 9:59:54 AM</li>
<li>SHA1: CC9D8220B2179E784D85BF1EA98D2EE2190D534F</li>
<li>ISO/CRC: 5DF6DBA0</li>
<li>Size: 2,385.99 (MB)</li>
</ul>
</li>
<li>Windows 7 Home Basic (x86) &#8211; DVD (English)
<ul>
<li>File Name: en_windows_7_home_basic_x86_dvd_x15-65654.iso</li>
<li>Date Posted (UTC): 8/6/2009 9:59:54 AM</li>
<li>SHA1: 101574FAA17FDB430BB027271EF0A58F0E18AD47</li>
<li>ISO/CRC: 2B06C5CC</li>
<li>Size: 2,385.99 (MB)</li>
</ul>
</li>
<li>Windows 7 Starter (x86) &#8211; DVD (English)
<ul>
<li>File Name: en_windows_7_starter_x86_dvd_x15-68956.iso</li>
<li>Date Posted (UTC): 8/6/2009 9:59:54 AM</li>
<li>SHA1: 5DC1457BC4B3D94097F499B15DFDB3C21DADCDF5</li>
<li>ISO/CRC: 43DE3418</li>
<li>2,385.99 (MB)</li>
</ul>
</li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://www.ideaexcursion.com/2009/08/06/windows-7-rtm-download-details/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>HOWTO: Connect to MySQL in SSIS</title>
		<link>http://www.ideaexcursion.com/2009/06/04/howto-connect-to-mysql-in-ssis/</link>
		<comments>http://www.ideaexcursion.com/2009/06/04/howto-connect-to-mysql-in-ssis/#comments</comments>
		<pubDate>Thu, 04 Jun 2009 14:58:43 +0000</pubDate>
		<dc:creator>Taylor Gerring</dc:creator>
				<category><![CDATA[Google]]></category>
		<category><![CDATA[SSIS]]></category>
		<category><![CDATA[MySQL]]></category>
		<category><![CDATA[SQL Server]]></category>

		<guid isPermaLink="false">http://www.ideaexcursion.com/?p=793</guid>
		<description><![CDATA[Using the MySQL ADO.NET provider, SQL Server Integration Services can natively query MySQL databases, providing an easy method to transfer data between systems.]]></description>
			<content:encoded><![CDATA[<p>While Microsoft provided <a title="SSIS Team Blog New connectivity options in 2008" href="http://blogs.msdn.com/mattm/archive/2008/03/10/new-connectivity-options-in-2008.aspx" target="_blank">connectors for Oracle, Teradata, and SAP BI</a> for <abbr title="SQL Server Integration Services">SSIS</abbr> 2008, there are many other database systems left out of the mix. Fortunately, <abbr title="SQL Server Integration Services">SSIS</abbr> is exceptionally flexible in connecting to various data sources and allows other vendors to provide native support. The MySQL team did just that with <a title="MySQL :: Download Connector/Net 6.0" href="http://dev.mysql.com/downloads/connector/net/6.0.html" target="_blank">Connector/NET 6.0</a>, their ADO.NET provider. This tool allows us to use the the ADO.NET connections in SQL Server Integration Services to easily connect to MySQL. This is a walk through on how to connect to MySQL with <abbr title="SQL Server Integration Services">SSIS</abbr> 2005 utilizing the Connector/NET 6.0 ADO.NET provider.<br />
<span id="more-793"></span></p>
<ol>
<li>Download and install MySQL <a title="MySQL :: Download Connector/Net 6.0" href="http://dev.mysql.com/downloads/connector/net/6.0.html" target="_blank">Connector/NET 6.0</a></li>
<li>Start a new Integration Services project in <acronym title="Business Intelligence Development Studio">BIDS</acronym>
</li>
<li>Right-click in Connection Managers and create a new ADO.NET Connection
<p><a rel="attachment wp-att-808" href="http://www.ideaexcursion.com/2009/06/04/howto-connect-to-mysql-in-ssis/new-ado-net-connection/"><img class="size-medium wp-image-808" title="New ADO.NET Connection" src="http://www.ideaexcursion.com/wp-content/uploads/2009/05/new-ado-net-connection-250x300.png" alt="New ADO.NET Connection" width="250" height="300" /></a></li>
<li>In the Provider dropdown, expand .Net Providers and select MySQL Data Provider. Press &quot;OK&quot;
<p><a rel="attachment wp-att-807" href="http://www.ideaexcursion.com/2009/06/04/howto-connect-to-mysql-in-ssis/mysql-data-provider/"><img class="size-medium wp-image-807" title="MySQL Data Provider" src="http://www.ideaexcursion.com/wp-content/uploads/2009/05/mysql-data-provider-300x201.png" alt="MySQL Data Provider" width="300" height="201" /></a></li>
<li>Fill out the Server name, User name, Password and select the database name for the target MySQL server. Be sure to test the connection and press &#8220;OK&#8221;
<p><a rel="attachment wp-att-799" href="http://www.ideaexcursion.com/2009/06/04/howto-connect-to-mysql-in-ssis/connection-manager-connection-info/"><img class="size-medium wp-image-799" title="Connection Manager Connection Info" src="http://www.ideaexcursion.com/wp-content/uploads/2009/05/connection-manager-connection-info-294x300.png" alt="Connection Manager Connection Info" width="294" height="300" /></a></li>
<li>Rename the connection to &#8220;MySQLDB&#8221;
<p><a rel="attachment wp-att-800" href="http://www.ideaexcursion.com/2009/06/04/howto-connect-to-mysql-in-ssis/connection-managers-mysqldb/"><img class="size-full wp-image-800" title="Connection Managers MySQLDB" src="http://www.ideaexcursion.com/wp-content/uploads/2009/05/connection-managers-mysqldb.png" alt="Connection Managers MySQLDB" width="143" height="50" /></a></li>
<li>Open up the Toolbox and drag a Data Flow Task from the toolbox onto the Control Flow surface
<div id="attachment_795" class="wp-caption alignnone" style="width: 310px"><a rel="attachment wp-att-795" href="http://www.ideaexcursion.com/2009/06/04/howto-connect-to-mysql-in-ssis/add-dataflowtask/"><img class="size-medium wp-image-795" title="Add Dataflow Task" src="http://www.ideaexcursion.com/wp-content/uploads/2009/05/add-dataflowtask-300x76.png" alt="Add Dataflow Task" width="300" height="76" /></a><p class="wp-caption-text">Add Dataflow Task</p></div>
</li>
<li>Double-click the Data Flow Task to switch to the Data Flow view</li>
<li>Create a new variable, &#8220;MySQLResult&#8221; with the Data Type of Object. We will be using this as the final destination for the data, so we don&#8217;t need to connect to a file or database to store the data from this test
<p><div id="attachment_812" class="wp-caption alignnone" style="width: 310px"><a rel="attachment wp-att-812" href="http://www.ideaexcursion.com/2009/06/04/howto-connect-to-mysql-in-ssis/variables-mysqlresult/"><img class="size-medium wp-image-812" title="MySQLResult Variable" src="http://www.ideaexcursion.com/wp-content/uploads/2009/05/variables-mysqlresult-300x66.png" alt="MySQLResult Variable" width="300" height="66" /></a><p class="wp-caption-text">MySQLResult Variable</p></div></li>
<li>Drag a new DataReader Source component onto the Data Flow surface
<p><div id="attachment_796" class="wp-caption alignnone" style="width: 310px"><a rel="attachment wp-att-796" href="http://www.ideaexcursion.com/2009/06/04/howto-connect-to-mysql-in-ssis/add-datareader-source/"><img class="size-medium wp-image-796" title="Add DataReader Source" src="http://www.ideaexcursion.com/wp-content/uploads/2009/05/add-datareader-source-300x78.png" alt="Add DataReader Source" width="300" height="78" /></a><p class="wp-caption-text">Add DataReader Source</p></div></li>
<li>Double-click the DataReader Source to open the Advanced Editor. On the Connection Managers tab, select the previously-created MySQLDB connection
<p><div id="attachment_805" class="wp-caption alignnone" style="width: 310px"><a rel="attachment wp-att-805" href="http://www.ideaexcursion.com/2009/06/04/howto-connect-to-mysql-in-ssis/datareader-source-connection-managers/"><img class="size-medium wp-image-805" title="DataReader Source Connection Managers" src="http://www.ideaexcursion.com/wp-content/uploads/2009/05/datareader-source-connection-managers-300x290.png" alt="DataReader Source Connection Managers" width="300" height="290" /></a><p class="wp-caption-text">DataReader Source Connection Managers</p></div>
</li>
<li>Switch to the Component Properties tab and enter the SQL query in the SqlCommand property. Note that the query must be compatible with MySQL syntax, not SQL Server.
<p><div id="attachment_804" class="wp-caption alignnone" style="width: 310px"><a rel="attachment wp-att-804" href="http://www.ideaexcursion.com/2009/06/04/howto-connect-to-mysql-in-ssis/datareader-source-component-properties/"><img class="size-medium wp-image-804" title="DataReader Source Component Properties" src="http://www.ideaexcursion.com/wp-content/uploads/2009/05/datareader-source-component-properties-300x269.png" alt="DataReader Source Component Properties" width="300" height="269" /></a><p class="wp-caption-text">DataReader Source Component Properties</p></div>
</li>
<li>Switch to the Column Mappings tab to verify that the query is successful and the all the columns were pulled from the database. When done, press &#8220;OK&#8221;.
<div id="attachment_803" class="wp-caption alignnone" style="width: 310px"><a rel="attachment wp-att-803" href="http://www.ideaexcursion.com/2009/06/04/howto-connect-to-mysql-in-ssis/datareader-soruce-column-mappings/"><img class="size-medium wp-image-803" title="DataReader Source Column Mappings" src="http://www.ideaexcursion.com/wp-content/uploads/2009/05/datareader-soruce-column-mappings-300x269.png" alt="DataReader Source Column Mappings" width="300" height="269" /></a><p class="wp-caption-text">DataReader Source Column Mappings</p></div></li>
<li>Create a new Recordset Destination by dragging it from the toolbox to the Data Flow surface
<p><div id="attachment_797" class="wp-caption alignnone" style="width: 310px"><a rel="attachment wp-att-797" href="http://www.ideaexcursion.com/2009/06/04/howto-connect-to-mysql-in-ssis/add-recordset-destination/"><img class="size-medium wp-image-797" title="Add Recordset Destination" src="http://www.ideaexcursion.com/wp-content/uploads/2009/05/add-recordset-destination-300x102.png" alt="Add Recordset Destination" width="300" height="102" /></a><p class="wp-caption-text">Add Recordset Destination</p></div>
</li>
<li>Drag the green Data Flow Path from DataReader Source to Recordset Destination, so they connect
<p><div id="attachment_801" class="wp-caption alignnone" style="width: 170px"><a rel="attachment wp-att-801" href="http://www.ideaexcursion.com/2009/06/04/howto-connect-to-mysql-in-ssis/connect-source-destination/"><img class="size-full wp-image-801" title="Connect Source to Destination" src="http://www.ideaexcursion.com/wp-content/uploads/2009/05/connect-source-destination.png" alt="Connect Source to Destination" width="160" height="145" /></a><p class="wp-caption-text">Connect Source to Destination</p></div></li>
<li>Double-click the Recordset Destination to open its Advanced Editor</li>
<li>Under Custom Properties, select the dropdown for VariableName and select the variable we created before, User::MySQLResult
<p><div id="attachment_810" class="wp-caption alignnone" style="width: 310px"><a rel="attachment wp-att-810" href="http://www.ideaexcursion.com/2009/06/04/howto-connect-to-mysql-in-ssis/recordset-destination-component-properties/"><img class="size-medium wp-image-810" title="Recordset Destination Component Properties" src="http://www.ideaexcursion.com/wp-content/uploads/2009/05/recordset-destination-component-properties-300x269.png" alt="Recordset Destination Component Properties" width="300" height="269" /></a><p class="wp-caption-text">Recordset Destination Component Properties</p></div></li>
<li>Switch to the Input Columns tab and select those columns that you want stored in the Recordset Destination. When complete, click &#8220;OK&#8221;
<p><div id="attachment_811" class="wp-caption alignnone" style="width: 308px"><a rel="attachment wp-att-811" href="http://www.ideaexcursion.com/2009/06/04/howto-connect-to-mysql-in-ssis/recordset-destination-input-columns/"><img class="size-medium wp-image-811" title="Recordset Destination Input Columns" src="http://www.ideaexcursion.com/wp-content/uploads/2009/05/recordset-destination-input-columns-298x300.png" alt="Recordset Destination Input Columns" width="298" height="300" /></a><p class="wp-caption-text">Recordset Destination Input Columns</p></div>
</li>
<li>Right-click the green Data Flow Path and choose &#8220;Data Viewers&#8230;&#8221;
<p><div id="attachment_813" class="wp-caption alignnone" style="width: 264px"><a rel="attachment wp-att-813" href="http://www.ideaexcursion.com/2009/06/04/howto-connect-to-mysql-in-ssis/data-flow-path-data-viewers/"><img class="size-medium wp-image-813" title="Data Flow Path Data Viewers" src="http://www.ideaexcursion.com/wp-content/uploads/2009/05/data-flow-path-data-viewers-254x300.png" alt="Data Flow Path Data Viewers" width="254" height="300" /></a><p class="wp-caption-text">Data Flow Path Data Viewers</p></div>
</li>
<li>Select &#8220;Data Viewers&#8221; from the left pane and click the &#8220;Add&#8230;&#8221; button
<p><div id="attachment_802" class="wp-caption alignnone" style="width: 310px"><a rel="attachment wp-att-802" href="http://www.ideaexcursion.com/2009/06/04/howto-connect-to-mysql-in-ssis/data-flow-path-editor/"><img class="size-medium wp-image-802" title="Data Flow Path Editor" src="http://www.ideaexcursion.com/wp-content/uploads/2009/05/data-flow-path-editor-300x253.png" alt="Data Flow Path Editor" width="300" height="253" /></a><p class="wp-caption-text">Data Flow Path Editor</p></div>
</li>
<li>Under the General tab, select Grid and press &#8220;OK&#8221;
<p><div id="attachment_798" class="wp-caption alignnone" style="width: 310px"><a rel="attachment wp-att-798" href="http://www.ideaexcursion.com/2009/06/04/howto-connect-to-mysql-in-ssis/configure-data-viewer/"><img class="size-medium wp-image-798" title="Configure Data Viewer" src="http://www.ideaexcursion.com/wp-content/uploads/2009/05/configure-data-viewer-300x229.png" alt="Configure Data Viewer" width="300" height="229" /></a><p class="wp-caption-text">Configure Data Viewer</p></div></li>
<li>Run the package</li>
<li>If you&#8217;ve done everything correctly, you should see a Data Reader Output Data Viewer window pop up with the contents of the query we specified earlier.
<p><div id="attachment_806" class="wp-caption alignnone" style="width: 310px"><a rel="attachment wp-att-806" href="http://www.ideaexcursion.com/2009/06/04/howto-connect-to-mysql-in-ssis/data-viewer-output/"><img class="size-medium wp-image-806" title="Data Viewer Output" src="http://www.ideaexcursion.com/wp-content/uploads/2009/05/data-viewer-output-300x165.png" alt="Data Viewer Output" width="300" height="165" /></a><p class="wp-caption-text">Data Viewer Output</p></div></li>
</ol>
<p>SQL Server Integration Services makes connecting to other systems very easy. The MySQL ADO.NET provider works well, but requires more configuration than a native Source component.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.ideaexcursion.com/2009/06/04/howto-connect-to-mysql-in-ssis/feed/</wfw:commentRss>
		<slash:comments>8</slash:comments>
		</item>
		<item>
		<title>Flatten Heirarchies in SQL Server with Common Table Expressions</title>
		<link>http://www.ideaexcursion.com/2009/05/12/flatten-heirarchies-in-sql-server-with-common-table-expressions/</link>
		<comments>http://www.ideaexcursion.com/2009/05/12/flatten-heirarchies-in-sql-server-with-common-table-expressions/#comments</comments>
		<pubDate>Tue, 12 May 2009 14:41:57 +0000</pubDate>
		<dc:creator>Taylor Gerring</dc:creator>
				<category><![CDATA[SQL Server]]></category>
		<category><![CDATA[SQL]]></category>
		<category><![CDATA[SQL Server 2005]]></category>
		<category><![CDATA[SQL Server 2008]]></category>
		<category><![CDATA[T-SQL]]></category>

		<guid isPermaLink="false">http://www.ideaexcursion.com/?p=731</guid>
		<description><![CDATA[Use a CTE to recursively roll up all descendant records into separate groups, regardless of level. Example data and Common Table Expression code included.]]></description>
			<content:encoded><![CDATA[<p>Common Table Expressions were a new feature added to SQL Server 2005 and provide an efficient way to recursively query relationships stored in a normalized table. We&#8217;re going to build on that essential functionality to flatten a typical corporate structure so that all children, grand children, great grand children, etc. roll up into a single, flattened parent, regardless of depth. To graphically visualize this, take a look at the actual relationship we&#8217;ll be querying against:<br />
<span id="more-731"></span><br />
<div id="attachment_772" class="wp-caption alignnone" style="width: 310px"><a href="http://www.ideaexcursion.com/2009/05/12/flatten-heirarchies-in-sql-server-with-common-table-expressions/actual-relationship/" rel="attachment wp-att-772"><img src="http://www.ideaexcursion.com/wp-content/uploads/2009/05/actual-relationship-300x211.png" alt="Actual employee structure to be flattened" title="Actual Relationship" width="300" height="211" class="size-medium wp-image-772" /></a><p class="wp-caption-text">Actual employee structure to be flattened</p></div></p>
<p>This structure will act as our example for the Development Department. The Department Head (Employee 0) has asked for a report of all employees within each team of the development group. Notice that different groups have varying levels of depth. The Database team only has a Manager with two direct reports. The <abbr title="User Interface">UI</abbr> team is a single person. The Middle Tier group is much larger, with a Manager having two direct reports, and one of those employees having several employees beneath him. The requested report should group all employees, flattening the relationship to a single Manager, but excluding himself (since that would mean every employee would simply roll up to him). This &#8220;Desired Relationship&#8221; is represented below:</p>
<div id="attachment_771" class="wp-caption alignnone" style="width: 310px"><a href="http://www.ideaexcursion.com/2009/05/12/flatten-heirarchies-in-sql-server-with-common-table-expressions/desired-relationship/" rel="attachment wp-att-771"><img src="http://www.ideaexcursion.com/wp-content/uploads/2009/05/desired-relationship-300x80.png" alt="The desired result of the query" title="Desired Relationship" width="300" height="80" class="size-medium wp-image-771" /></a><p class="wp-caption-text">The desired result of the query</p></div>
<p>To recreate this scenario, I&#8217;m providing some code for both the setup and query. If you&#8217;re not familiar with Common Table Expressions, I would suggest that you familiarize yourself with the <a href="http://msdn.microsoft.com/en-us/library/ms186243.aspx" title="SQL Server Books Online">SQL Server <abbr title="Books Online">BOL</abbr> entry</a>. The main concept you should understand to be able to adapt this to your own data is that for a <abbr title="Common Table Expression">CTE</abbr> to act recursively, you need both an anchor and recursive query. I&#8217;ll explain their parts later.</p>
<p>First, let&#8217;s instantiate the tables and populate them with data:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
</pre></td><td class="code"><pre class="tsql" style="font-family:monospace;"><span style="color: #0000FF;">USE</span> tempdb
go
&nbsp;
<span style="color: #0000FF;">IF</span> <span style="color: #FF00FF;">OBJECT_ID</span><span style="color: #808080;">&#40;</span><span style="color: #FF0000;">'dbo.Employees'</span><span style="color: #808080;">&#41;</span> <span style="color: #0000FF;">IS</span> not null
	<span style="color: #0000FF;">DROP</span> <span style="color: #0000FF;">TABLE</span> dbo.<span style="color: #202020;">Employees</span>
go
&nbsp;
<span style="color: #0000FF;">CREATE</span> <span style="color: #0000FF;">TABLE</span> dbo.<span style="color: #202020;">Employees</span>
<span style="color: #808080;">&#40;</span>
	  EmployeeID <span style="color: #0000FF;">INT</span> <span style="color: #0000FF;">PRIMARY</span> <span style="color: #0000FF;">KEY</span>
	, EmployeeName <span style="color: #0000FF;">VARCHAR</span><span style="color: #808080;">&#40;</span><span style="color: #000;">50</span><span style="color: #808080;">&#41;</span> not null
	, ManagerEmployeeID <span style="color: #0000FF;">INT</span> null
<span style="color: #808080;">&#41;</span>
go
&nbsp;
<span style="color: #0000FF;">INSERT</span> <span style="color: #0000FF;">INTO</span> dbo.<span style="color: #202020;">Employees</span> <span style="color: #808080;">&#40;</span>EmployeeID, EmployeeName, ManagerEmployeeID<span style="color: #808080;">&#41;</span>
<span style="color: #0000FF;">SELECT</span> <span style="color: #000;">0</span>, <span style="color: #FF0000;">'Employee 0'</span>, null
<span style="color: #0000FF;">UNION</span> all
<span style="color: #0000FF;">SELECT</span> <span style="color: #000;">1</span>, <span style="color: #FF0000;">'Employee 1'</span>, <span style="color: #000;">0</span>
<span style="color: #0000FF;">UNION</span> all
<span style="color: #0000FF;">SELECT</span> <span style="color: #000;">2</span>, <span style="color: #FF0000;">'Employee 2'</span>, <span style="color: #000;">0</span>
<span style="color: #0000FF;">UNION</span> all
<span style="color: #0000FF;">SELECT</span> <span style="color: #000;">3</span>, <span style="color: #FF0000;">'Employee 3'</span>, <span style="color: #000;">0</span>
<span style="color: #0000FF;">UNION</span> all
<span style="color: #0000FF;">SELECT</span> <span style="color: #000;">4</span>, <span style="color: #FF0000;">'Employee 1.1'</span>, <span style="color: #000;">1</span>
<span style="color: #0000FF;">UNION</span> all
<span style="color: #0000FF;">SELECT</span> <span style="color: #000;">5</span>, <span style="color: #FF0000;">'Employee 1.2'</span>, <span style="color: #000;">1</span>
<span style="color: #0000FF;">UNION</span> all
<span style="color: #0000FF;">SELECT</span> <span style="color: #000;">6</span>, <span style="color: #FF0000;">'Employee 3.1'</span>, <span style="color: #000;">3</span>
<span style="color: #0000FF;">UNION</span> all
<span style="color: #0000FF;">SELECT</span> <span style="color: #000;">7</span>, <span style="color: #FF0000;">'Employee 3.2'</span>, <span style="color: #000;">3</span>
<span style="color: #0000FF;">UNION</span> all
<span style="color: #0000FF;">SELECT</span> <span style="color: #000;">8</span>, <span style="color: #FF0000;">'Employee 3.1.1'</span>, <span style="color: #000;">6</span>
<span style="color: #0000FF;">UNION</span> all
<span style="color: #0000FF;">SELECT</span> <span style="color: #000;">9</span>, <span style="color: #FF0000;">'Employee 3.1.1.1'</span>, <span style="color: #000;">8</span>
go</pre></td></tr></table></div>

<p>This script will simply create the example employees table and populate it with data to relationally represent what is displayed in the first picture. Here are what the various lines accomplish:</p>
<ul>
<li>1-2: Switch the database context to tempdb. Since the contents of tempdb are cleared upon service restart, we&#8217;re simply ensuring that this will be cleaned up eventually.</li>
<li>4-6: Check if dbo.Employees exists. If so, drop it.</li>
<li>8-14: Create a table to hold our example data.</li>
<li>16-36: Manually populate the example data. Note that we&#8217;re using a UNION ALL between the selects, so only a single INSERT occurs.</li>
</ul>
<p>As for the query to manipulate this data, here is the actual <abbr title="Common Table Expression">CTE</abbr>:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
</pre></td><td class="code"><pre class="tsql" style="font-family:monospace;"><span style="color: #008080;">-- Use a CTE to flatten an organization structure to each department</span>
<span style="color: #0000FF;">WITH</span> AllMyChildren <span style="color: #808080;">&#40;</span>ManagerEmployeeID, EmployeeID, GroupManagerID, EmployeeName, <span style="color: #0000FF;">DEPTH</span><span style="color: #808080;">&#41;</span>
<span style="color: #0000FF;">AS</span>
<span style="color: #808080;">&#40;</span>
	<span style="color: #008080;">-- The anchor statement. This selects each department head</span>
	<span style="color: #008080;">-- The important part is to alias the original EmployeeID as the GroupManagerID</span>
	<span style="color: #0000FF;">SELECT</span> ManagerEmployeeID, EmployeeID, EmployeeID <span style="color: #808080;">&#91;</span>GroupManagerID<span style="color: #808080;">&#93;</span>, EmployeeName, <span style="color: #000;">0</span> <span style="color: #808080;">&#91;</span><span style="color: #0000FF;">DEPTH</span><span style="color: #808080;">&#93;</span>
	<span style="color: #0000FF;">FROM</span> dbo.<span style="color: #202020;">Employees</span> <span style="color: #0000FF;">WHERE</span> EmployeeID in
		<span style="color: #008080;">-- We want all employees 1 level below below a certain level, so we'll utilize a subquery to find them</span>
		<span style="color: #808080;">&#40;</span>
		<span style="color: #008080;">-- Get EmployeeIDs that are children to their common parent</span>
		<span style="color: #0000FF;">SELECT</span> EmployeeID <span style="color: #0000FF;">FROM</span> dbo.<span style="color: #202020;">Employees</span> <span style="color: #0000FF;">WHERE</span> ManagerEmployeeID <span style="color: #808080;">=</span> <span style="color: #000;">0</span>
		<span style="color: #808080;">&#41;</span>
	<span style="color: #0000FF;">UNION</span> <span style="color: #808080;">ALL</span>
	<span style="color: #008080;">-- The recursive statement which finds all employees under each department</span>
	<span style="color: #0000FF;">SELECT</span> pc.<span style="color: #202020;">ManagerEmployeeID</span>, pc.<span style="color: #202020;">EmployeeID</span>, amc.<span style="color: #202020;">GroupManagerID</span>, pc.<span style="color: #202020;">EmployeeName</span>, <span style="color: #0000FF;">DEPTH</span> <span style="color: #808080;">+</span> <span style="color: #000;">1</span>
	<span style="color: #0000FF;">FROM</span> dbo.<span style="color: #202020;">Employees</span> pc
	<span style="color: #0000FF;">INNER</span> join AllMyChildren amc <span style="color: #0000FF;">ON</span> pc.<span style="color: #202020;">ManagerEmployeeID</span> <span style="color: #808080;">=</span> amc.<span style="color: #202020;">EmployeeID</span>
<span style="color: #808080;">&#41;</span>
<span style="color: #008080;">-- The CTE is primed, but we still need to execute it with the statement below</span>
<span style="color: #0000FF;">SELECT</span> EmployeeName, GroupManagerID, <span style="color: #0000FF;">DEPTH</span> 
<span style="color: #0000FF;">FROM</span> AllMyChildren
<span style="color: #0000FF;">ORDER</span> <span style="color: #0000FF;">BY</span> GroupManagerID, <span style="color: #0000FF;">DEPTH</span>
<span style="color: #008080;">-- Use the MAXRECURSION query hint to avoid default recursion limit of 100</span>
<span style="color: #0000FF;">OPTION</span> <span style="color: #808080;">&#40;</span>MAXRECURSION <span style="color: #000;">0</span><span style="color: #808080;">&#41;</span></pre></td></tr></table></div>

<p>I&#8217;ve commented liberally, but I&#8217;ll go through this line-by-line to explain it in more detail.</p>
<ul>
<li>2-4: Define the <abbr title="Common Table Expression">CTE</abbr> (AllMyChildren) and the columns that it will output (ManagerEmployeeID, EmployeeID, GroupManagerID, EmployeeName, Depth)</li>
<li>7-8: This is the anchor statement. SELECT the fields we eventually want outputted. The key to this is that EmployeeID is being included a second time, but aliased as GroupManagerID.</li>
<li>10-13: This is a subquery in the WHERE condition of the anchor statement. Because we want to discard some levels (only the topmost level in our example), we need to tell the anchor to fetch all children whose parent EmployeeID is 0. Adjust this sub-query to affect at what level the teams should roll up to.</li>
<li>14-18: UNION ALL the anchor to the recursive portion of the <abbr title="Common Table Expression">CTE</abbr>. The recursive part of the query is similar to the anchor in that it must SELECT similar columns. Notice that it again selects from dbo.Employees, but it also performs an INNER JOIN against the <abbr title="Common Table Expression">CTE</abbr>, linking the EmployeeID and ManagerEmployeeID. This is what causes to recursion to occur. Additionally, we increment Depth by 1. The inclusion of the level is completely optional in the <abbr title="Common Table Expression">CTE</abbr>, but may be helpful for reporting.</li>
<li>19: Close the <abbr title="Common Table Expression">CTE</abbr> block. At this point, it is defined, but we have yet to execute it.</li>
<li>21-23: Perform a SELECT against the <abbr title="Common Table Expression">CTE</abbr> to start it.</li>
<li>25: By default, recursion in Common Table Expressions is limited to 100 iterations. If you anticipate having more than 100 records, you&#8217;ll need to specify MAXRECURSION 0. When testing, you can limit it to any number up to 32,767 to prevent wild-running queries. Here &#8211; since this is tested and working &#8211; we specify &#8220;0&#8243; for unlimited iterations.</li>
</ul>
<p>And this is the result of the above query:<br />
<div id="attachment_766" class="wp-caption alignnone" style="width: 283px"><a href="http://www.ideaexcursion.com/2009/05/12/flatten-heirarchies-in-sql-server-with-common-table-expressions/query-result/" rel="attachment wp-att-766"><img src="http://www.ideaexcursion.com/wp-content/uploads/2009/05/query-result.png" alt="The tabular results of the query" title="Query Result" width="273" height="191" class="size-full wp-image-766" /></a><p class="wp-caption-text">The tabular results of the query</p></div><br />
Notice that the GroupManagerID is the same for each team, regardless of depth. Also, the Depth corresponds to how far down the tree each employee exist. I&#8217;ve conveniently coded the EmployeeName in dot-notation to make the comparison much simpler.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.ideaexcursion.com/2009/05/12/flatten-heirarchies-in-sql-server-with-common-table-expressions/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Control Startup Program Order with PowerShell</title>
		<link>http://www.ideaexcursion.com/2009/04/14/control-startup-program-order-with-powershell/</link>
		<comments>http://www.ideaexcursion.com/2009/04/14/control-startup-program-order-with-powershell/#comments</comments>
		<pubDate>Tue, 14 Apr 2009 13:27:55 +0000</pubDate>
		<dc:creator>Taylor Gerring</dc:creator>
				<category><![CDATA[Windows]]></category>
		<category><![CDATA[HOWTO]]></category>
		<category><![CDATA[PowerShell]]></category>

		<guid isPermaLink="false">http://www.ideaexcursion.com/?p=673</guid>
		<description><![CDATA[A highly flexible way to ensure programs are started under the correct conditions, in the proper sequence, with timed delay.]]></description>
			<content:encoded><![CDATA[<p>If you&#8217;re like me and need multiple programs to start upon login, your hard drive is likely inundated with requests, causing a major slowdown as the OS seeks to fill each and every request simultaneously. Furthermore, I have some programs that are dependent upon others, so when they load out of order, I have to shutdown and restart the applications or perform some extra steps to reconfigure the program. An example of this is <a title="HOWTO: Synchronize Dropbox and ZumoDrive on Windows" href="http://www.ideaexcursion.com/2009/02/26/howto-synchronize-dropbox-and-zumodrive-on-windows/">synchronizing DropBox and ZumoDrive</a>. If DropBox starts before ZumoDrive, it never syncs and hangs in an &#8220;Indexing&#8230;&#8221; state. This matter is complicated by storing my KeePass database on my ZumoDrive. Because KeePass loads before ZumoDrive, it can&#8217;t find the Z: location and I have to re-locate the KDB file for it to load.</p>
<p>One solution to this problem is to start the programs manually, which is monotonous. A much better solution is to control the exact startup sequence, giving each program a small delay to fully load before starting the next program. A solution I used in the past for Windows was a batch file. This suffers from a couple of problems:</p>
<ol>
<li>By default, there is no &#8220;sleep&#8221; command. You can install the Windows 2003 Administrator Toolkit for the functionality, or resort to a ping delay trick. Both of these are less-than-ideal.</li>
<li>This is 2009. Batch files aren&#8217;t exactly cool.</li>
</ol>
<p>To overcome these issues, I took a gander at my latest favorite scripting language, <a title="Windows PowerShell" href="http://www.microsoft.com/windowsserver2003/technologies/management/powershell/default.mspx" target="_blank">PowerShell</a>; it handily solves both issues. This is a very easy hack and to accomplish it, there are only a few steps. The only considerations for this project is to ensure that PowerShell v1 or v2 is installed and <a title="Windows PowerShell: Securing the Shell" href="http://technet.microsoft.com/en-us/magazine/cc137808.aspx" target="_blank">configured to run scripts locally</a>. With those assumptions, let&#8217;s get started:<br />
<span id="more-673"></span></p>
<h3>Create the script</h3>
<p>Let&#8217;s get directly to the fun stuff. Because we&#8217;re only performing 2 types of actions, the script itself is actually very simple. The hardest part of this step is locating each program. Create a new PowerShell script called Startup.ps1 and save it in your (My) Documents folder. Copy my example script to get started:</p>

<div class="wp_syntax"><div class="code"><pre class="powershell" style="font-family:monospace;"><span style="color: #008080; font-weight: bold;">Start-Sleep</span> –s <span style="color: #000000;">15</span>
<span style="color: pink;">&amp;</span> <span style="color: #800000;">'C:\Program Files\Zecter\ZumoDrive\zumodrive.exe'</span>
<span style="color: #008080; font-weight: bold;">Start-Sleep</span> –s <span style="color: #000000;">5</span>
<span style="color: pink;">&amp;</span> <span style="color: #800000;">'C:\Program Files\Dropbox\Dropbox.exe'</span> <span style="color: pink;">/</span>home
<span style="color: #008080; font-weight: bold;">Start-Sleep</span> –s <span style="color: #000000;">5</span>
<span style="color: pink;">&amp;</span> <span style="color: #800000;">'C:\Program Files\Digsby\Digsby.exe'</span>
<span style="color: #008080; font-weight: bold;">Start-Sleep</span> –s <span style="color: #000000;">15</span>
<span style="color: pink;">&amp;</span> <span style="color: #800000;">'C:\Program Files\KeePass Password Safe\KeePass.exe'</span></pre></div></div>

<p>The Start-Sleep command suspends the script for a specific amount of time. By specifying the &#8220;-s 15&#8243; parameter, we provide a delay of 15 seconds. I provide an initial delay on load of the script simply to ensure the OS has loaded other necessary modules.</p>
<p>The second type of line is the actual execution of a program. The command is an ampersand (&amp;) followed by the program path enclosed in single quotes. Any program parameters can go after the path name. The use of single quotes (&#39;) indicates we are passing a literal string. If we were to use double-quotes instead, PowerShell would attempt to interpret any variables enclosed, of which we have none.</p>
<p>Cofigure your script with the programs you want started at logon. A good solution to this is to check the properties of each program in your start menu. For anything not in your Start Menu, you&#8217;ll have to locate the application. We&#8217;ll test the script a bit later.</p>
<h3>Turn off automatic startups</h3>
<p>This step is a bit more complicated, because you may need to go into each program and turn off the &#8220;Automatically start when I log on to Windows&#8221; option. A quick way to head off most of these issues is through the msconfig tool. Simply start msconfig (XP: Start&rarr;Run&rarr;msconfig. Vista: Start&rarr;mscofig).</p>
<div id="attachment_685" class="wp-caption alignnone" style="width: 274px"><a rel="attachment wp-att-685" href="http://www.ideaexcursion.com/2009/04/14/control-startup-program-order-with-powershell/run-msconfig/"><img class="size-full wp-image-685" title="Run msconfig utility" src="http://www.ideaexcursion.com/wp-content/uploads/2009/04/run-msconfig.png" alt="Run msconfig utility" width="264" height="92" /></a><p class="wp-caption-text">Run msconfig utility</p></div>
<p>Switch to the Startup tab and uncheck items you plan to load through your custom logon script. When done, click &#8220;OK&#8221;.</p>
<div id="attachment_681" class="wp-caption alignnone" style="width: 310px"><a rel="attachment wp-att-681" href="http://www.ideaexcursion.com/2009/04/14/control-startup-program-order-with-powershell/msconfig-startup/"><img class="size-medium wp-image-681" title="System Configuration Startup" src="http://www.ideaexcursion.com/wp-content/uploads/2009/04/msconfig-startup-300x199.png" alt="System Configuration Startup" width="300" height="199" /></a><p class="wp-caption-text">System Configuration Startup</p></div>
<h3>Link your Startup Script</h3>
<p>The final step is to actually enable the startup script. Navigate to your Startup program folder. The easiest way to accomplish this is to find the Startup folder in your Start Menu, Right-click, and select &#8220;Open&#8221;.</p>
<div id="attachment_683" class="wp-caption alignnone" style="width: 244px"><a rel="attachment wp-att-683" href="http://www.ideaexcursion.com/2009/04/14/control-startup-program-order-with-powershell/open-startupfolder/"><img class="size-full wp-image-683" title="Open Startup folder" src="http://www.ideaexcursion.com/wp-content/uploads/2009/04/open-startupfolder.png" alt="Open Startup folder" width="234" height="111" /></a><p class="wp-caption-text">Open Startup folder</p></div>
<p>A new folder will open and you want to create a new shortcut here. Right-click in an empty spot in the folder and choose New&rarr;Shortcut.</p>
<div id="attachment_682" class="wp-caption alignnone" style="width: 310px"><a rel="attachment wp-att-682" href="http://www.ideaexcursion.com/2009/04/14/control-startup-program-order-with-powershell/newshortcut/"><img class="size-medium wp-image-682" title="New Shortcut" src="http://www.ideaexcursion.com/wp-content/uploads/2009/04/newshortcut-300x31.png" alt="New Shortcut" width="300" height="31" /></a><p class="wp-caption-text">New Shortcut</p></div>
<p>A Wizard will open prompting your for the location of the item. In the text box, put &#8220;powershell .\Startup.ps1&#8243;.</p>
<div id="attachment_686" class="wp-caption alignnone" style="width: 310px"><a rel="attachment wp-att-686" href="http://www.ideaexcursion.com/2009/04/14/control-startup-program-order-with-powershell/shortcut-location/"><img class="size-medium wp-image-686" title="Shortcut Location" src="http://www.ideaexcursion.com/wp-content/uploads/2009/04/shortcut-location-300x222.png" alt="Shortcut Location" width="300" height="222" /></a><p class="wp-caption-text">Shortcut Location</p></div>
<p>Technically, you can provide the absolute path to the item, but we&#8217;ll utilize a slightly different method. Click &#8220;Next&#8221; and name the shortcut to your liking, maybe, &#8220;Default Startup&#8221;.</p>
<div id="attachment_687" class="wp-caption alignnone" style="width: 310px"><a rel="attachment wp-att-687" href="http://www.ideaexcursion.com/2009/04/14/control-startup-program-order-with-powershell/shortcut-name/"><img class="size-medium wp-image-687" title="Shortcut Name" src="http://www.ideaexcursion.com/wp-content/uploads/2009/04/shortcut-name-300x222.png" alt="Shortcut Name" width="300" height="222" /></a><p class="wp-caption-text">Shortcut Name</p></div>
<p>When the wizard closes, switch back to the Startup folder and you should see your new shortcut. Right-click the shortcut and select &#8220;Properties&#8221;.</p>
<div id="attachment_684" class="wp-caption alignnone" style="width: 239px"><a rel="attachment wp-att-684" href="http://www.ideaexcursion.com/2009/04/14/control-startup-program-order-with-powershell/rightclick-properties/"><img class="size-medium wp-image-684" title="Properties link" src="http://www.ideaexcursion.com/wp-content/uploads/2009/04/rightclick-properties-229x300.png" alt="Properties link" width="229" height="300" /></a><p class="wp-caption-text">Properties link</p></div>
<p>Take note that the &#8220;Target&#8221; field has been expanded to the full path to PowerShell. For example, &#8220;C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe .\Startup.ps1&#8243;. We want to edit the field directly below it, labeled &#8220;Start in&#8221;. Delete the contents of the field and replace it with &quot;%USERPROFILE%\Documents&quot; for Vista or &quot;%USERPROFILE%\My Documents&quot;. Go ahead and include double-quotes just for completeness. When done, click &#8220;OK&#8221;.</p>
<div id="attachment_688" class="wp-caption alignnone" style="width: 228px"><a rel="attachment wp-att-688" href="http://www.ideaexcursion.com/2009/04/14/control-startup-program-order-with-powershell/shortcut-properties/"><img class="size-medium wp-image-688" title="Shortcut Properties" src="http://www.ideaexcursion.com/wp-content/uploads/2009/04/shortcut-properties-218x300.png" alt="Shortcut Properties" width="218" height="300" /></a><p class="wp-caption-text">Shortcut Properties</p></div>
<h3>Testing</h3>
<p>When you&#8217;re done, it&#8217;s best to exit all the programs and run the script, ensuring there are no errors. To correctly configure the delay times, you may want to reboot, which ensures the memory cache is clear. You can then jot down which programs need more or less time.</p>
<p>To test, simply double-click the shortcut. If all goes according to plan, all your programs should launch just as before. And because the shortcut it located in the Startup folder, this should happen each time you log in to your profile.</p>
<p>For me, this is a great, simple solution using a tool I already have installed on my computer. Additionally, as my needs change, it gives me ultimate flexibility in the future. I could even go so far as to conditionally launch programs depending on aspects like date and time.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.ideaexcursion.com/2009/04/14/control-startup-program-order-with-powershell/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
	</channel>
</rss>
