<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="http://sqlblog.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>SSIS Junkie : nugget</title><link>http://sqlblog.com/blogs/jamie_thomson/archive/tags/nugget/default.aspx</link><description>Tags: nugget</description><dc:language>en</dc:language><generator>CommunityServer 2.1 SP2 (Build: 61129.1)</generator><item><title>SSIS gotcha: Beware of multiple outputs from a synchronous script component</title><link>http://sqlblog.com/blogs/jamie_thomson/archive/2010/07/04/ssis-gotcha-beware-of-multiple-outputs-from-a-synchronous-script-component.aspx</link><pubDate>Sun, 04 Jul 2010 20:43:12 GMT</pubDate><guid isPermaLink="false">21093a07-8b3d-42db-8cbf-3350fcbf5496:26727</guid><dc:creator>jamiet</dc:creator><slash:comments>1</slash:comments><comments>http://sqlblog.com/blogs/jamie_thomson/comments/26727.aspx</comments><wfw:commentRss>http://sqlblog.com/blogs/jamie_thomson/commentrss.aspx?PostID=26727</wfw:commentRss><wfw:comment>http://sqlblog.com/blogs/jamie_thomson/rsscomments.aspx?PostID=26727</wfw:comment><description>&lt;p&gt;A few days ago I was &lt;a href="http://social.msdn.microsoft.com/Forums/en-US/sqlintegrationservices/thread/c0f2b376-66a3-49d8-8925-ada9a362ba53/?prof=required" target="_blank"&gt;alerted&lt;/a&gt; to a peculiarity of SSIS’s Script Component that I believe people need to be aware of. Its a peculiarity that can rear its head when your script component is &lt;strong&gt;synchronous and has multiple outputs&lt;/strong&gt;. Here’s an example of a dataflow that contains such a component:&lt;/p&gt;  &lt;blockquote&gt;   &lt;p&gt;&lt;a href="http://sqlblog.com/blogs/jamie_thomson/image_71055C17.png"&gt;&lt;img style="border-bottom:0px;border-left:0px;display:inline;border-top:0px;border-right:0px;" class="wlDisabledImage" title="ssis dataflow with a script component with multiple synchronous outputs" border="0" alt="ssis dataflow with a script component with multiple synchronous outputs" src="http://sqlblog.com/blogs/jamie_thomson/image_thumb_12A184E9.png" width="596" height="312" /&gt;&lt;/a&gt;&lt;/p&gt; &lt;/blockquote&gt;  &lt;p&gt;Some things to note about this dataflow that you can’t tell from this screenshot:&lt;/p&gt;  &lt;ul&gt;   &lt;li&gt;The source component will create a 1-row,1-column dataset with the value “1” in it&lt;/li&gt;    &lt;li&gt;Even though it has three outputs “SCR Send data to multiple outputs” is still a synchronous component*&lt;/li&gt; &lt;/ul&gt;  &lt;blockquote&gt;   &lt;p&gt;&lt;em&gt;*If you don’t understand how a synchronous component can have multiple outputs and/or have never heard of an Exclusion Group then you should go and read my blog post from 2005 &lt;/em&gt;&lt;a href="http://consultingblogs.emc.com/jamiethomson/archive/2005/09/05/SSIS-Nugget_3A00_-Multiple-outputs-from-a-synchronous-script-transform.aspx" target="_blank"&gt;&lt;em&gt;Multiple outputs from a synchronous script transform&lt;/em&gt;&lt;/a&gt;&lt;em&gt; – the blog post you’re reading right now won’t make much sense without it! If you have ever used the Multicast component then it shouldn’t surprise you that a synchronous component can have multiple outputs – because that’s a pretty good definition of what the Multicast component does!&lt;/em&gt;&lt;/p&gt; &lt;/blockquote&gt;  &lt;p&gt;Here’s the important code inside “SCR Send data to multiple outputs”:&lt;/p&gt;  &lt;blockquote&gt;   &lt;p&gt;&lt;a href="http://sqlblog.com/blogs/jamie_thomson/image_055AFBD6.png"&gt;&lt;img style="border-bottom:0px;border-left:0px;display:inline;border-top:0px;border-right:0px;" class="wlDisabledImage" title="script component code multiple outputs" border="0" alt="script component code multiple outputs" src="http://sqlblog.com/blogs/jamie_thomson/image_thumb_5D484CB6.png" width="592" height="198" /&gt;&lt;/a&gt;&lt;/p&gt; &lt;/blockquote&gt;  &lt;p&gt;The code:&lt;/p&gt;  &lt;ul&gt;   &lt;li&gt;increments the incoming value and puts it into Output0&lt;/li&gt;    &lt;li&gt;increments the value again and puts it into Output1&lt;/li&gt;    &lt;li&gt;increments the value again and puts it into Output2&lt;/li&gt; &lt;/ul&gt;  &lt;p&gt;Given that out starting value is “1” you might expect that our three outputs would contain the values “2”, “3” &amp;amp; “4” respectively but in fact that is not the case. Here is what we actually see in those three outputs when we execute the dataflow:&lt;/p&gt;  &lt;blockquote&gt;   &lt;p&gt;&lt;a href="http://sqlblog.com/blogs/jamie_thomson/image_0984D39B.png"&gt;&lt;img style="border-bottom:0px;border-left:0px;display:inline;border-top:0px;border-right:0px;" class="wlDisabledImage" title="SSIS data viewers, multiple outputs" border="0" alt="SSIS data viewers, multiple outputs" src="http://sqlblog.com/blogs/jamie_thomson/image_thumb_07D407C7.png" width="475" height="175" /&gt;&lt;/a&gt;&lt;/p&gt;    &lt;p&gt;&lt;a href="http://sqlblog.com/blogs/jamie_thomson/image_054AD609.png"&gt;&lt;img style="border-bottom:0px;border-left:0px;display:inline;border-top:0px;border-right:0px;" class="wlDisabledImage" title="ssis executed dataflow" border="0" alt="ssis executed dataflow" src="http://sqlblog.com/blogs/jamie_thomson/image_thumb_428B8AD0.png" width="595" height="302" /&gt;&lt;/a&gt;&lt;/p&gt; &lt;/blockquote&gt;  &lt;p&gt;Each of our outputs has the same value “4”. Why is that? The trick is in understanding something fundamental about synchronous components, &lt;em&gt;they only ever output the same number of rows as are input&lt;/em&gt;.&amp;#160; The fact that in the data flow above it appears as though three rows have been output is simply an illusion that is best explained by former SSIS Development Manager Kirk Haselden who left the following comment on my &lt;a href="http://consultingblogs.emc.com/jamiethomson/archive/2005/09/05/SSIS-Nugget_3A00_-Multiple-outputs-from-a-synchronous-script-transform.aspx" target="_blank"&gt;blog post&lt;/a&gt; that I linked to earlier:&lt;/p&gt;  &lt;blockquote&gt;   &lt;p&gt;&lt;em&gt;The additional or duplicate rows are an illusion. The Dataflow Task actually tracks what buffer columns and rows are visible to the downstream transforms, but doesn't copy any buffers or rows. It simply &amp;quot;exposes&amp;quot; them with row and column views.        &lt;br /&gt;Truly, the synchronous outputs only send the same number of columns* as they receive on their inputs.         &lt;br /&gt;&lt;/em&gt;&lt;em&gt;- Kirk Haselden, 15th March 2006       &lt;br /&gt;&lt;font size="1"&gt;*This is a typo. Kirk meant to say “rows” not “columns”&lt;/font&gt;&lt;/em&gt;&lt;/p&gt; &lt;/blockquote&gt;  &lt;p&gt;In our case the script component has simply incremented the same value three times and we are looking at that same incremented value of “4” in each of our outputs.&lt;/p&gt;  &lt;p&gt;I have produced a short video that demonstrates this behaviour using the dataflow pictured above. Embedding videos here on SQLBlog is however a fiddly experience so for ease I’ll just direct you to view it on Vimeo at &lt;a href="http://vimeo.com/13081087" target="_blank"&gt;Multiple Outputs from a synchronous script component&lt;/a&gt;.&lt;/p&gt;  &lt;p&gt;Hope this helps. Any questions please put them in the comments.&lt;/p&gt;  &lt;p&gt;&lt;a href="http://twitter.com/jamiet" target="_blank"&gt;@JamieT&lt;/a&gt;&lt;/p&gt;&lt;img src="http://sqlblog.com/aggbug.aspx?PostID=26727" width="1" height="1"&gt;</description><category domain="http://sqlblog.com/blogs/jamie_thomson/archive/tags/dataflow/default.aspx">dataflow</category><category domain="http://sqlblog.com/blogs/jamie_thomson/archive/tags/nugget/default.aspx">nugget</category><category domain="http://sqlblog.com/blogs/jamie_thomson/archive/tags/sql+server+integration+services/default.aspx">sql server integration services</category><category domain="http://sqlblog.com/blogs/jamie_thomson/archive/tags/ssis/default.aspx">ssis</category><category domain="http://sqlblog.com/blogs/jamie_thomson/archive/tags/synchronous+components/default.aspx">synchronous components</category><category domain="http://sqlblog.com/blogs/jamie_thomson/archive/tags/video/default.aspx">video</category></item><item><title>Dynamic Unpivot : SSIS Nugget</title><link>http://sqlblog.com/blogs/jamie_thomson/archive/2010/05/29/dynamic-unpivot-ssis-nugget.aspx</link><pubDate>Sat, 29 May 2010 06:10:00 GMT</pubDate><guid isPermaLink="false">21093a07-8b3d-42db-8cbf-3350fcbf5496:25686</guid><dc:creator>jamiet</dc:creator><slash:comments>12</slash:comments><comments>http://sqlblog.com/blogs/jamie_thomson/comments/25686.aspx</comments><wfw:commentRss>http://sqlblog.com/blogs/jamie_thomson/commentrss.aspx?PostID=25686</wfw:commentRss><wfw:comment>http://sqlblog.com/blogs/jamie_thomson/rsscomments.aspx?PostID=25686</wfw:comment><description>&lt;P&gt;A &lt;A href="http://social.msdn.microsoft.com/Forums/en-US/sqlintegrationservices/thread/82d0f1bd-112a-4612-8723-d657b31bdbde"&gt;question on the SSIS forum&lt;/A&gt; earlier today asked:&lt;/P&gt;
&lt;BLOCKQUOTE&gt;
&lt;P&gt;&lt;EM&gt;I need to dynamically unpivot some set of columns in my source file. Every month there is one new column and its set of Values. I want to unpivot it without editing my SSIS packages that is deployed&lt;/EM&gt;&lt;/P&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Let’s be clear about what we mean by Unpivot. It is a normalisation technique that basically converts columns into rows. By way of example it converts something like this:&lt;/P&gt;
&lt;BLOCKQUOTE&gt;
&lt;TABLE cellSpacing=0 cellPadding=2&gt;

&lt;TR&gt;
&lt;TD&gt;&lt;STRONG&gt;AccountCode&lt;/STRONG&gt;&lt;/TD&gt;
&lt;TD&gt;&lt;STRONG&gt;Jan&lt;/STRONG&gt;&lt;/TD&gt;
&lt;TD&gt;&lt;STRONG&gt;Feb&lt;/STRONG&gt;&lt;/TD&gt;
&lt;TD&gt;&lt;STRONG&gt;Mar&lt;/STRONG&gt;&lt;/TD&gt;&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;AC1&lt;/TD&gt;
&lt;TD&gt;100.00&lt;/TD&gt;
&lt;TD&gt;150.00&lt;/TD&gt;
&lt;TD&gt;125.00&lt;/TD&gt;&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;AC2&lt;/TD&gt;
&lt;TD&gt;45.00&lt;/TD&gt;
&lt;TD&gt;75.50&lt;/TD&gt;
&lt;TD&gt;90.00&lt;/TD&gt;&lt;/TR&gt;&lt;/TABLE&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;into something like this:&lt;/P&gt;
&lt;BLOCKQUOTE&gt;
&lt;TABLE cellSpacing=0 cellPadding=2&gt;

&lt;TR&gt;
&lt;TD&gt;&lt;STRONG&gt;AccountCode&lt;/STRONG&gt;&lt;/TD&gt;
&lt;TD&gt;&lt;STRONG&gt;Month&lt;/STRONG&gt;&lt;/TD&gt;
&lt;TD&gt;&lt;STRONG&gt;Amount&lt;/STRONG&gt;&lt;/TD&gt;&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;AC1&lt;/TD&gt;
&lt;TD&gt;Jan&lt;/TD&gt;
&lt;TD&gt;100.00&lt;/TD&gt;&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;AC1&lt;/TD&gt;
&lt;TD&gt;Feb&lt;/TD&gt;
&lt;TD&gt;150.00&lt;/TD&gt;&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;AC1&lt;/TD&gt;
&lt;TD&gt;Mar&lt;/TD&gt;
&lt;TD&gt;125.00&lt;/TD&gt;&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;AC2&lt;/TD&gt;
&lt;TD&gt;Jan&lt;/TD&gt;
&lt;TD&gt;45.00&lt;/TD&gt;&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;AC2&lt;/TD&gt;
&lt;TD&gt;Feb&lt;/TD&gt;
&lt;TD&gt;75.50&lt;/TD&gt;&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;AC2&lt;/TD&gt;
&lt;TD&gt;Mar&lt;/TD&gt;
&lt;TD&gt;90.00&lt;/TD&gt;&lt;/TR&gt;&lt;/TABLE&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;The Unpivot transformation in SSIS is perfectly capable of carrying out the operation defined in this example however in the case outlined in the aforementioned forum thread the problem was a little bit different. I interpreted it to mean that the number of columns could change and in that scenario the Unpivot transformation (and indeed the SSIS dataflow in general) is rendered useless because it expects that the number of columns will not change from what is specified at design-time.&lt;/P&gt;
&lt;P&gt;There is a workaround however. Assuming all of the columns that CAN exist will appear at the end of the rows, we can (1) import all of the columns in the file as just a single column, (2) use a script component to loop over all the values in that “column” and (3) output each one as a column all of its own. Let’s go over that in a bit more detail.&lt;/P&gt;
&lt;P&gt;I’ve prepared a data file that shows some data that we want to unpivot which shows some customers and their mythical shopping lists (it has column names in the first row):&lt;/P&gt;
&lt;BLOCKQUOTE&gt;
&lt;P&gt;&lt;A href="http://sqlblog.com/blogs/jamie_thomson/clip_image002_11DE2EB3.jpg"&gt;&lt;IMG style="BORDER-BOTTOM:0px;BORDER-LEFT:0px;DISPLAY:inline;BORDER-TOP:0px;BORDER-RIGHT:0px;" title=clip_image002 border=0 alt=clip_image002 src="http://sqlblog.com/blogs/jamie_thomson/clip_image002_thumb_45767544.jpg" width=430 height=274&gt;&lt;/A&gt;&lt;/P&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;We use a Flat File Connection Manager to specify the format of our data file to SSIS:&lt;/P&gt;
&lt;BLOCKQUOTE&gt;
&lt;P&gt;&lt;A href="http://sqlblog.com/blogs/jamie_thomson/clip_image004_1814DF74.jpg"&gt;&lt;IMG style="BORDER-BOTTOM:0px;BORDER-LEFT:0px;DISPLAY:inline;BORDER-TOP:0px;BORDER-RIGHT:0px;" title=clip_image004 border=0 alt=clip_image004 src="http://sqlblog.com/blogs/jamie_thomson/clip_image004_thumb_0ED8A433.jpg" width=544 height=555&gt;&lt;/A&gt;&lt;/P&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;and a Flat File Source Adapter to put it into the dataflow (no need a for a screenshot of that one – its very basic).&lt;/P&gt;
&lt;P&gt;Notice that the values that we want to unpivot all exist in a column called [Groceries]. Now onto the script component where the real work goes on, although the code is pretty simple:&lt;/P&gt;
&lt;BLOCKQUOTE&gt;
&lt;P&gt;&lt;A href="http://sqlblog.com/blogs/jamie_thomson/clip_image006_45664F77.jpg"&gt;&lt;IMG style="BORDER-BOTTOM:0px;BORDER-LEFT:0px;DISPLAY:inline;BORDER-TOP:0px;BORDER-RIGHT:0px;" title=clip_image006 border=0 alt=clip_image006 src="http://sqlblog.com/blogs/jamie_thomson/clip_image006_thumb_16C020C8.jpg" width=947 height=526&gt;&lt;/A&gt;&lt;/P&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Here I show a screenshot of this executing along with some data viewers. As you can see we have successfully pulled out all of the values into a row all of their own thus accomplishing the Dynamic Unpivot that the forum poster was after.&lt;/P&gt;
&lt;BLOCKQUOTE&gt;
&lt;P&gt;&lt;A href="http://sqlblog.com/blogs/jamie_thomson/clip_image008_39C06C6B.jpg"&gt;&lt;IMG style="BORDER-BOTTOM:0px;BORDER-LEFT:0px;DISPLAY:inline;BORDER-TOP:0px;BORDER-RIGHT:0px;" title=clip_image008 border=0 alt=clip_image008 src="http://sqlblog.com/blogs/jamie_thomson/clip_image008_thumb_7A33091A.jpg" width=968 height=591&gt;&lt;/A&gt;&lt;/P&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;If you want to run the demo for yourself then I have uploaded the demo package and source file up to my SkyDrive: &lt;A title=http://cid-550f681dad532637.skydrive.live.com/self.aspx/Public/BlogShare/20100529/Dynamic%20Unpivot.zip href="http://cid-550f681dad532637.skydrive.live.com/self.aspx/Public/BlogShare/20100529/Dynamic%20Unpivot.zip"&gt;http://cid-550f681dad532637.skydrive.live.com/self.aspx/Public/BlogShare/20100529/Dynamic%20Unpivot.zip&lt;/A&gt;&amp;nbsp;The package was builton SSIS 2008.&lt;/P&gt;
&lt;P&gt;Simply extract the two files into a folder, make sure the Connection Manager is pointing to the file, and execute!&lt;/P&gt;
&lt;P&gt;Hope this is useful.&lt;/P&gt;
&lt;P&gt;&lt;A href="http://twitter.com/jamiet" target=_blank&gt;@Jamiet&lt;/A&gt;&lt;/P&gt;&lt;img src="http://sqlblog.com/aggbug.aspx?PostID=25686" width="1" height="1"&gt;</description><category domain="http://sqlblog.com/blogs/jamie_thomson/archive/tags/nugget/default.aspx">nugget</category><category domain="http://sqlblog.com/blogs/jamie_thomson/archive/tags/sql+server+integration+services/default.aspx">sql server integration services</category><category domain="http://sqlblog.com/blogs/jamie_thomson/archive/tags/ssis/default.aspx">ssis</category><category domain="http://sqlblog.com/blogs/jamie_thomson/archive/tags/Unpivot/default.aspx">Unpivot</category></item><item><title>FileNameColumnName property, Flat File Source Adapter : SSIS Nugget</title><link>http://sqlblog.com/blogs/jamie_thomson/archive/2010/03/31/filenamecolumnname-property-flat-file-source-adapter-ssis-nugget.aspx</link><pubDate>Wed, 31 Mar 2010 21:51:11 GMT</pubDate><guid isPermaLink="false">21093a07-8b3d-42db-8cbf-3350fcbf5496:23930</guid><dc:creator>jamiet</dc:creator><slash:comments>12</slash:comments><comments>http://sqlblog.com/blogs/jamie_thomson/comments/23930.aspx</comments><wfw:commentRss>http://sqlblog.com/blogs/jamie_thomson/commentrss.aspx?PostID=23930</wfw:commentRss><wfw:comment>http://sqlblog.com/blogs/jamie_thomson/rsscomments.aspx?PostID=23930</wfw:comment><description>&lt;p&gt; I saw a question on MSDN’s SSIS forum the other day that went something like this:&lt;/p&gt;  &lt;blockquote&gt;   &lt;p&gt;&lt;em&gt;I’m loading data into a table from a flat file but I want to be able to store the name of that file as well. Is there a way of doing that?&lt;/em&gt;&lt;/p&gt; &lt;/blockquote&gt;  &lt;p&gt;I don’t want to come across as disrespecting those who took the time to reply but there was a few answers along the lines of “loop over the files using a For Each, store the file name in a variable yadda yadda yadda” when in fact there is a much much simpler way of accomplishing this; it just happens to be a little hidden away as I shall now explain!&lt;/p&gt;  &lt;p&gt;The &lt;a href="http://msdn.microsoft.com/en-us/library/ms139941.aspx" target="_blank"&gt;Flat File Source Adapter&lt;/a&gt; has a property called &lt;a href="http://msdn.microsoft.com/en-us/library/ms135923.aspx#flatfile" target="_blank"&gt;FileNameColumnName&lt;/a&gt;&lt;font face="Courier New"&gt;&lt;/font&gt; which for some reason it isn’t exposed through the Flat File Source editor, it &lt;em&gt;is&lt;/em&gt; however exposed via the Advanced Properties:&lt;/p&gt;  &lt;blockquote&gt;   &lt;p&gt;&lt;a href="http://sqlblog.com/blogs/jamie_thomson/cid_image001_png01CAD0EF_7160518C.png"&gt;&lt;img style="border-bottom:0px;border-left:0px;display:inline;border-top:0px;border-right:0px;" title="flat file source adapter advanced properties" border="0" alt="flat file source adapter advanced properties" src="http://sqlblog.com/blogs/jamie_thomson/cid_image001_png01CAD0EF_thumb_04052577.png" width="512" height="523" /&gt;&lt;/a&gt;&lt;/p&gt; &lt;/blockquote&gt;  &lt;p&gt;You’ll see in the screenshot above that I have set&lt;/p&gt;  &lt;blockquote&gt;   &lt;p&gt;FileNameColumnName=“Filename”&lt;/p&gt; &lt;/blockquote&gt;  &lt;p&gt;(it doesn’t matter what name you use, anything except a non-zero string will work). What this will do is create a new column in our dataflow called “Filename” that contains, unsurprisingly, the name of the file from which the row was sourced. All very simple. This is particularly useful if you are extracting data from multiple files using the &lt;a href="http://msdn.microsoft.com/en-us/library/ms137830.aspx" target="_blank"&gt;MultiFlatFile Connection Manager&lt;/a&gt; as it allows you to differentiate between data from each of the files as you can see in the following screenshot:&lt;/p&gt;  &lt;blockquote&gt;   &lt;p&gt;&lt;a href="http://sqlblog.com/blogs/jamie_thomson/image_0BECA20C.png"&gt;&lt;img style="border-bottom:0px;border-left:0px;display:inline;border-top:0px;border-right:0px;" title="filename data viewer" border="0" alt="filename data viewer" src="http://sqlblog.com/blogs/jamie_thomson/image_thumb_56FF9CCE.png" width="357" height="523" /&gt;&lt;/a&gt; &lt;/p&gt; &lt;/blockquote&gt;  &lt;p&gt;So there you have it, the &lt;font face="Courier New"&gt;FileNameColumnName &lt;/font&gt;property; a little known secret of SSIS. I hope it proves to be useful to someone out there.&lt;/p&gt;  &lt;p&gt;&lt;a href="http://twitter.com/jamiet" target="_blank"&gt;@Jamiet&lt;/a&gt;&lt;/p&gt;&lt;img src="http://sqlblog.com/aggbug.aspx?PostID=23930" width="1" height="1"&gt;</description><category domain="http://sqlblog.com/blogs/jamie_thomson/archive/tags/FileNameColumnName/default.aspx">FileNameColumnName</category><category domain="http://sqlblog.com/blogs/jamie_thomson/archive/tags/flat+file+source/default.aspx">flat file source</category><category domain="http://sqlblog.com/blogs/jamie_thomson/archive/tags/nugget/default.aspx">nugget</category><category domain="http://sqlblog.com/blogs/jamie_thomson/archive/tags/sql+server+integration+services/default.aspx">sql server integration services</category><category domain="http://sqlblog.com/blogs/jamie_thomson/archive/tags/ssis/default.aspx">ssis</category></item><item><title>Parsing flat files using SSIS : SSIS Nugget</title><link>http://sqlblog.com/blogs/jamie_thomson/archive/2010/03/25/parsing-flat-files-using-ssis-ssis-nugget.aspx</link><pubDate>Wed, 24 Mar 2010 23:11:00 GMT</pubDate><guid isPermaLink="false">21093a07-8b3d-42db-8cbf-3350fcbf5496:23716</guid><dc:creator>jamiet</dc:creator><slash:comments>6</slash:comments><comments>http://sqlblog.com/blogs/jamie_thomson/comments/23716.aspx</comments><wfw:commentRss>http://sqlblog.com/blogs/jamie_thomson/commentrss.aspx?PostID=23716</wfw:commentRss><wfw:comment>http://sqlblog.com/blogs/jamie_thomson/rsscomments.aspx?PostID=23716</wfw:comment><description>&lt;P&gt;Often when using SQL Server Integration Services (SSIS) you will find there is more than one way of accomplishing a task and that the most obvious method of doing so might not be the optimal one. In the video below I demonstrate this by way of an experiment using SSIS’s Flat File Source component; I show different ways that you can pull data from a flat file into the SSIS dataflow and also how the nature of the data itself can influence your choice as to how this task should be accomplished.&lt;/P&gt;
&lt;OBJECT&gt;
&lt;embed style="WIDTH:600px;HEIGHT:450px;" src="http://vimeo.com/moogaloop.swf?clip_id=10417434&amp;amp;server=vimeo.com&amp;amp;show_title=1&amp;amp;show_byline=1&amp;amp;show_portrait=0&amp;amp;color=00ADEF&amp;amp;fullscreen=1" allowfullscreen="true"&gt;&lt;/embed&gt;&lt;/OBJECT&gt;
&lt;BLOCKQUOTE&gt;
&lt;P&gt;&lt;EM&gt;If you are having trouble viewing the video in your blog reader then head to&amp;nbsp;&lt;/EM&gt;&lt;A href="http://sqlblog.com/blogs/jamie_thomson/archive/2010/03/25/parsing-flat-files-using-ssis-ssis-nugget.aspx"&gt;&lt;EM&gt;http://sqlblog.com/blogs/jamie_thomson/archive/2010/03/25/parsing-flat-files-using-ssis-ssis-nugget.aspx&lt;/EM&gt;&lt;/A&gt;&lt;EM&gt;&amp;nbsp;to see it as it is hosted on my blog!&lt;/EM&gt;&amp;nbsp;&lt;/P&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;The main point I want to get across from this video is that a little bit of creative thinking when building your dataflows can sometimes be very beneficial for performance; quite often building a solution that isn’t the most obvious might actually turn out to be the best one.&lt;/P&gt;
&lt;P&gt;You’ll notice, if you have watched the video, that my editing skills weren’t quite up to snuff and I cut off the final few words however all I was saying was that if you have any feedback on this video then I would love to hear it either via email or preferably the comments section below. I hope this turns out to be useful to some of you.&lt;/P&gt;
&lt;P&gt;&lt;A href="http://twitter.com/jamiet" target=_blank&gt;@Jamiet&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;P.S. Incidentally the parsing that we do using SSIS expressions in the video would be much easier if we had a TOKENISE function in SSIS’s expression language and I have asked for the introduction of such a function on Connect at &lt;A href="https://connect.microsoft.com/SQLServer/feedback/details/543945/ssis-token-string-tokeniser-string-occurence-function" target=_blank&gt;[SSIS] TOKEN(string, tokeniser_string, occurence) function&lt;/A&gt;. Feel free to go and vote that up if you think this feature would be useful!&lt;/P&gt;&lt;img src="http://sqlblog.com/aggbug.aspx?PostID=23716" width="1" height="1"&gt;</description><category domain="http://sqlblog.com/blogs/jamie_thomson/archive/tags/flat+file+source/default.aspx">flat file source</category><category domain="http://sqlblog.com/blogs/jamie_thomson/archive/tags/nugget/default.aspx">nugget</category><category domain="http://sqlblog.com/blogs/jamie_thomson/archive/tags/sql+server+integration+services/default.aspx">sql server integration services</category><category domain="http://sqlblog.com/blogs/jamie_thomson/archive/tags/ssis/default.aspx">ssis</category><category domain="http://sqlblog.com/blogs/jamie_thomson/archive/tags/video/default.aspx">video</category></item><item><title>Destination Adapter Comparison : SSIS Video Nugget</title><link>http://sqlblog.com/blogs/jamie_thomson/archive/2010/03/02/destination-adapter-comparison-ssis-video-nugget.aspx</link><pubDate>Tue, 02 Mar 2010 12:11:00 GMT</pubDate><guid isPermaLink="false">21093a07-8b3d-42db-8cbf-3350fcbf5496:22728</guid><dc:creator>jamiet</dc:creator><slash:comments>5</slash:comments><comments>http://sqlblog.com/blogs/jamie_thomson/comments/22728.aspx</comments><wfw:commentRss>http://sqlblog.com/blogs/jamie_thomson/commentrss.aspx?PostID=22728</wfw:commentRss><wfw:comment>http://sqlblog.com/blogs/jamie_thomson/rsscomments.aspx?PostID=22728</wfw:comment><description>
&lt;p&gt;In this, my latest video nugget, I demonstrate and compare three ways that you can insert data into a SQL Server table from the SSIS DataFlow:&lt;/p&gt;
  
&lt;ul&gt;   
&lt;li&gt;OLE DB Destination without Fast Load &lt;/li&gt;
    
&lt;li&gt;OLE DB Destination with Fast Load &lt;/li&gt;
    
&lt;li&gt;SQL Server Destination &lt;/li&gt;
 &lt;/ul&gt;
  
&lt;p&gt;The demo peels back the covers to see how these three methods actually operate against the database. The video is embedded below however at the time of writing we are still having issues with getting videos to show up on SQLBlog meaning that the video may appear too small to view hence in the meantime I’ll refer you to view the video on Vimeo at &lt;a href="http://vimeo.com/9806121" title="http://vimeo.com/9806121"&gt;http://vimeo.com/9806121&lt;/a&gt; (it is 7m19s long).&lt;/p&gt;
  
&lt;p&gt;If after watching this you want to know any more then you may glean some useful information from my blog post &lt;a href="http://consultingblogs.emc.com/jamiethomson/archive/2006/08/14/SSIS_3A00_-Destination-Adapter-Comparison.aspx" target="_blank"&gt;SSIS: Destination Adapter Comparison&lt;/a&gt; from August 2006 or feel free to post any questions in the comments below and I’ll do my best to answer them! &lt;/p&gt;
  
&lt;p&gt;Hope this is useful!&lt;/p&gt;
  
&lt;p&gt;&lt;a href="http://twitter.com/jamiet" target="_blank"&gt;@Jamiet&lt;/a&gt;&lt;/p&gt;
 
&lt;embed src="http://vimeo.com/moogaloop.swf?clip_id=9806121&amp;amp;server=vimeo.com&amp;amp;show_title=1&amp;amp;show_byline=1&amp;amp;show_portrait=0&amp;amp;color=00ADEF&amp;amp;fullscreen=1" allowfullscreen="true" style="width:600px;height:450px;"&gt;&lt;a href="http://vimeo.com/moogaloop.swf?clip_id=9806121&amp;amp;server=vimeo.com&amp;amp;show_title=1&amp;amp;show_byline=1&amp;amp;show_portrait=0&amp;amp;color=00ADEF&amp;amp;fullscreen=1" class="onxldjuucmcshidmscok"&gt;&lt;/a&gt;&lt;a href="http://vimeo.com/moogaloop.swf?clip_id=9806121&amp;amp;server=vimeo.com&amp;amp;show_title=1&amp;amp;show_byline=1&amp;amp;show_portrait=0&amp;amp;color=00ADEF&amp;amp;fullscreen=1" class="onxldjuucmcshidmscok"&gt;&lt;/a&gt;&lt;a href="http://sqlblog.com/controlpanel/blogs/" class="onxldjuucmcshidmscok"&gt;&lt;/a&gt;&lt;a href="http://sqlblog.com/controlpanel/blogs/" class="onxldjuucmcshidmscok"&gt;&lt;/a&gt;&lt;a href="http://vimeo.com/moogaloop.swf?clip_id=9806121&amp;amp;server=vimeo.com&amp;amp;show_title=1&amp;amp;show_byline=1&amp;amp;show_portrait=0&amp;amp;color=00ADEF&amp;amp;fullscreen=1" class="onxldjuucmcshidmscok"&gt;&lt;/a&gt;&lt;a href="http://vimeo.com/moogaloop.swf?clip_id=9806121&amp;amp;server=vimeo.com&amp;amp;show_title=1&amp;amp;show_byline=1&amp;amp;show_portrait=0&amp;amp;color=00ADEF&amp;amp;fullscreen=1" class="onxldjuucmcshidmscok"&gt;&lt;/a&gt;&lt;a href="http://vimeo.com/moogaloop.swf?clip_id=9806121&amp;amp;server=vimeo.com&amp;amp;show_title=1&amp;amp;show_byline=1&amp;amp;show_portrait=0&amp;amp;color=00ADEF&amp;amp;fullscreen=1" class="onxldjuucmcshidmscok"&gt;&lt;/a&gt;&lt;a href="http://vimeo.com/moogaloop.swf?clip_id=9806121&amp;amp;server=vimeo.com&amp;amp;show_title=1&amp;amp;show_byline=1&amp;amp;show_portrait=0&amp;amp;color=00ADEF&amp;amp;fullscreen=1" class="onxldjuucmcshidmscok"&gt;&lt;/a&gt;&lt;a href="http://sqlblog.com/controlpanel/blogs/" class="onxldjuucmcshidmscok"&gt;&lt;/a&gt;&lt;a href="http://sqlblog.com/controlpanel/blogs/" class="onxldjuucmcshidmscok"&gt;&lt;/a&gt;&lt;img src="http://sqlblog.com/aggbug.aspx?PostID=22728" width="1" height="1"&gt;</description><category domain="http://sqlblog.com/blogs/jamie_thomson/archive/tags/dataflow/default.aspx">dataflow</category><category domain="http://sqlblog.com/blogs/jamie_thomson/archive/tags/nugget/default.aspx">nugget</category><category domain="http://sqlblog.com/blogs/jamie_thomson/archive/tags/OLE+DB+Destination/default.aspx">OLE DB Destination</category><category domain="http://sqlblog.com/blogs/jamie_thomson/archive/tags/sql+server+integration+services/default.aspx">sql server integration services</category><category domain="http://sqlblog.com/blogs/jamie_thomson/archive/tags/ssis/default.aspx">ssis</category><category domain="http://sqlblog.com/blogs/jamie_thomson/archive/tags/video/default.aspx">video</category></item><item><title>Outputting data to an XML file : SSIS video nugget</title><link>http://sqlblog.com/blogs/jamie_thomson/archive/2010/02/27/outputting-data-to-an-xml-file-ssis-video-nugget.aspx</link><pubDate>Sat, 27 Feb 2010 16:53:00 GMT</pubDate><guid isPermaLink="false">21093a07-8b3d-42db-8cbf-3350fcbf5496:22647</guid><dc:creator>jamiet</dc:creator><slash:comments>8</slash:comments><comments>http://sqlblog.com/blogs/jamie_thomson/comments/22647.aspx</comments><wfw:commentRss>http://sqlblog.com/blogs/jamie_thomson/commentrss.aspx?PostID=22647</wfw:commentRss><wfw:comment>http://sqlblog.com/blogs/jamie_thomson/rsscomments.aspx?PostID=22647</wfw:comment><description>
&lt;p&gt;The last &lt;a href="http://sqlblog.com/blogs/jamie_thomson/archive/tags/nugget/video/default.aspx" target="_blank"&gt;video nugget&lt;/a&gt; that I produced seemed to be &lt;a href="http://sqlblog.com/blogs/jamie_thomson/archive/2010/02/25/looping-over-sql-scripts-and-executing-them-ssis-video-nugget.aspx#comments" target="_blank"&gt;fairly well received&lt;/a&gt; so I thought I would attempt a few more; and indeed, here is the next one. In this video I demonstrate a simple technique for outputting data to an XML file using SSIS’s Script Task.&lt;/p&gt;
  
&lt;p&gt;The video is 8m22s long and is embedded below however I’m aware of some problems that we are having, at the time of writing, with embedding of videos here on SQLBlog so for the time being head over to &lt;a href="http://vimeo.com/9781950" title="http://vimeo.com/9781950"&gt;http://vimeo.com/9781950&lt;/a&gt; where it can be viewed.&lt;/p&gt;
  
&lt;p&gt;If you are so inclined I have made the package that I built whilst recording this demonstration available &lt;a href="http://cid-550f681dad532637.skydrive.live.com/self.aspx/Public/BlogShare/20100227/Output%20data%20to%20an%20XML%20file%20using%20SSIS.zip" target="_blank"&gt;on my SkyDrive&lt;/a&gt; for your reference.&lt;/p&gt;
  
&lt;p&gt;I look forward to your comments.&lt;/p&gt;
  
&lt;p&gt;&lt;a href="http://twitter.com/jamiet" target="_blank"&gt;@Jamiet&lt;/a&gt;&lt;/p&gt;
 
&lt;embed src="http://vimeo.com/moogaloop.swf?clip_id=9781950&amp;amp;server=vimeo.com&amp;amp;show_title=1&amp;amp;show_byline=1&amp;amp;show_portrait=0&amp;amp;color=00ADEF&amp;amp;fullscreen=1" allowfullscreen="true" style="width:600px;height:450px;"&gt;&lt;img src="http://sqlblog.com/aggbug.aspx?PostID=22647" width="1" height="1"&gt;</description><category domain="http://sqlblog.com/blogs/jamie_thomson/archive/tags/nugget/default.aspx">nugget</category><category domain="http://sqlblog.com/blogs/jamie_thomson/archive/tags/sql+server+integration+services/default.aspx">sql server integration services</category><category domain="http://sqlblog.com/blogs/jamie_thomson/archive/tags/ssis/default.aspx">ssis</category><category domain="http://sqlblog.com/blogs/jamie_thomson/archive/tags/video/default.aspx">video</category><category domain="http://sqlblog.com/blogs/jamie_thomson/archive/tags/XML/default.aspx">XML</category></item><item><title>Looping over SQL scripts and executing them : SSIS video nugget</title><link>http://sqlblog.com/blogs/jamie_thomson/archive/2010/02/25/looping-over-sql-scripts-and-executing-them-ssis-video-nugget.aspx</link><pubDate>Wed, 24 Feb 2010 23:02:00 GMT</pubDate><guid isPermaLink="false">21093a07-8b3d-42db-8cbf-3350fcbf5496:22604</guid><dc:creator>jamiet</dc:creator><slash:comments>12</slash:comments><comments>http://sqlblog.com/blogs/jamie_thomson/comments/22604.aspx</comments><wfw:commentRss>http://sqlblog.com/blogs/jamie_thomson/commentrss.aspx?PostID=22604</wfw:commentRss><wfw:comment>http://sqlblog.com/blogs/jamie_thomson/rsscomments.aspx?PostID=22604</wfw:comment><description>&lt;P&gt;Earlier today while surfing the &lt;A href="http://social.msdn.microsoft.com/forums/en-US/sqlintegrationservices/threads/" target=_blank&gt;SSIS forum on MSDN&lt;/A&gt; I noticed a question that asked &lt;A href="http://social.msdn.microsoft.com/Forums/en-US/sqlintegrationservices/thread/8765da99-edc4-4b64-a2dc-952da8a68c42" target=_blank&gt;how one could execute a series of .sql files using SSIS&lt;/A&gt;. One suggested approach was to read the contents of the file(s) into a variable using a Script Task and then execute the contents of that variable using an Execute SQL Task. Well, that would work but there is actually a much quicker and easier way and given that at least two people on that thread didn’t know about it I thought it might be worth putting together a little demo.&lt;/P&gt;
&lt;P&gt;I’ve produced a video, embedded below, that demonstrates this technique. Quite simply it loops over the .sql files in question and points the Execute SQL Task &lt;I&gt;directly&lt;/I&gt; at those files which saves us from having to read the file contents into a variable. The video is 5m31s long:&lt;/P&gt;&lt;EMBED style="WIDTH:600px;HEIGHT:450px;" src=http://vimeo.com/moogaloop.swf?clip_id=9714659&amp;amp;server=vimeo.com&amp;amp;show_title=1&amp;amp;show_byline=1&amp;amp;show_portrait=0&amp;amp;color=00ADEF&amp;amp;fullscreen=1 allowfullscreen="true"&gt; 
&lt;P&gt;If the video is not showing up for whatever reason then you can go and view it over at &lt;A title=http://vimeo.com/9714659 href="http://vimeo.com/9714659" target=_blank&gt;http://vimeo.com/9714659&lt;/A&gt;.&lt;/P&gt;
&lt;P&gt;That’s it, hope it was useful! Over on &lt;A href="http://consultingblogs.emc.com/jamiethomson/" target=_blank&gt;my old blog&lt;/A&gt; I used to produce a lot of these how-to blog posts and I termed them &lt;A href="http://consultingblogs.emc.com/jamiethomson/archive/tags/SSIS/Nugget/default.aspx" target=_blank&gt;SSIS Nuggets&lt;/A&gt; – I liked the connotation of them being bite-sized bits of info that you could easily consume. I’d like to get back into producing SSIS nuggets and I reckon that videos like this could be a useful way of communicating them. Does that sound like a good idea? Let me know in the comments!&lt;/P&gt;
&lt;P&gt;&lt;A href="http://twitter.com/jamiet" target=_blank&gt;@Jamiet&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;img src="http://sqlblog.com/aggbug.aspx?PostID=22604" width="1" height="1"&gt;</description><category domain="http://sqlblog.com/blogs/jamie_thomson/archive/tags/For+Each+Loop/default.aspx">For Each Loop</category><category domain="http://sqlblog.com/blogs/jamie_thomson/archive/tags/nugget/default.aspx">nugget</category><category domain="http://sqlblog.com/blogs/jamie_thomson/archive/tags/sql+server+integration+services/default.aspx">sql server integration services</category><category domain="http://sqlblog.com/blogs/jamie_thomson/archive/tags/ssis/default.aspx">ssis</category><category domain="http://sqlblog.com/blogs/jamie_thomson/archive/tags/video/default.aspx">video</category></item><item><title>SSIS Package Stats Collector version 2</title><link>http://sqlblog.com/blogs/jamie_thomson/archive/2009/11/07/ssis-package-stats-collector-version-2.aspx</link><pubDate>Sat, 07 Nov 2009 01:58:24 GMT</pubDate><guid isPermaLink="false">21093a07-8b3d-42db-8cbf-3350fcbf5496:18599</guid><dc:creator>jamiet</dc:creator><slash:comments>12</slash:comments><comments>http://sqlblog.com/blogs/jamie_thomson/comments/18599.aspx</comments><wfw:commentRss>http://sqlblog.com/blogs/jamie_thomson/commentrss.aspx?PostID=18599</wfw:commentRss><wfw:comment>http://sqlblog.com/blogs/jamie_thomson/rsscomments.aspx?PostID=18599</wfw:comment><description>&lt;p&gt;A few weeks ago I published a blog entitled &lt;a href="http://sqlblog.com/blogs/jamie_thomson/archive/2009/10/18/collecting-information-about-your-ssis-packages-ssis-nugget.aspx"&gt;Collecting information about your SSIS packages&lt;/a&gt; which demonstrated a way that you could use T-SQL and XQuery to derive information about your SSIS packages. Since then I’ve made a few amendments to the script that accompanied that blog post as follows:&lt;/p&gt;  &lt;h4&gt;New columns&lt;/h4&gt;  &lt;p&gt;The collected data now includes the following information about your packages:    &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; PackageId     &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; PackageXML&amp;#160; (The XML that forms the .dtsx file)     &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; NumberOfContainers     &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; NumberOfDataflows     &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; NumberOfConnectionManagers     &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; NumberOfVariablesInEntirePackage&lt;/p&gt;  &lt;h4&gt;New feature&lt;/h4&gt;  &lt;p&gt;Returns a list of non-unique GUIDs and the packages that they appear in. If a GUID appears more than once in the same package it tells us how many times&lt;/p&gt;  &lt;h4&gt;Bug fixes&lt;/h4&gt;  &lt;p&gt;If there were no tasks in the package no data would be returned. That is now no longer the case.    &lt;br /&gt;Previous version didn’t work on case-sensitive collations, should be OK now.&lt;/p&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;p&gt;There are also more comments liberally sprinkled around it now as well!&lt;/p&gt;  &lt;p&gt;Here’s a screenshot showing some of those new columns:&lt;/p&gt;  &lt;p&gt;&lt;a href="http://sqlblog.com/blogs/jamie_thomson/image_53C348EA.png"&gt;&lt;img style="border-right-width:0px;display:inline;border-top-width:0px;border-bottom-width:0px;border-left-width:0px;" title="image" border="0" alt="image" src="http://sqlblog.com/blogs/jamie_thomson/image_thumb_32BFB076.png" width="846" height="212" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;Returning [PackageId] as a field is an important addition because we can now very easily see if any of our packages share the same Package Id. Package IDs are supposed to be unique but if they are not then they are a problem waiting to happen and unfortunately Business Intelligence Design Studio (BIDS) doesn’t really protect you against it very well,&amp;#160; in fact if you use package templates then its very likely that you have non unique GUIDs somewhere. (“Non unique globally unique identifiers” – that should set the alarm bells ringing if nothing else).&lt;/p&gt;  &lt;p&gt;As alluded to above the script now returns a brand new dataset showing all the GUIDs that occur more than once across all of your packages. Now, I’m not just talking about PackageId GUIDs here, every single object in a SSIS package be it a task, container, component, variable, connection manager, column, whatever… has a GUID attached to it and given the healthy amount of copy-and-paste that goes on when developing SSIS packages its a sure bet that some of those GUIDs are going to get repeated somewhere. Of course, its up to you whether you want to do anything about it or not – if you’re a purist then the idea of repeated GUIDs might keep you awake at night although I suspect most people simply won’t care. Still, its there if you need it:&lt;/p&gt;  &lt;p&gt;&lt;a href="http://sqlblog.com/blogs/jamie_thomson/image_0DFE7332.png"&gt;&lt;img style="border-right-width:0px;display:inline;border-top-width:0px;border-bottom-width:0px;border-left-width:0px;" title="image" border="0" alt="image" src="http://sqlblog.com/blogs/jamie_thomson/image_thumb_37B1C858.png" width="918" height="223" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;You may wonder why I have the [NumberOfTimeshisGUIDOccursInThisPackage] column in there. Well, its perfectly plausible that the a GUID can reoccur in the same package and in fact when I was testing this earlier on today I had a package that had 6 occurrences of a GUID because it contained 6 near-identical connection managers that had obviously been copied-and-pasted.&lt;/p&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;p&gt;That’s it for now. Let me know if this script proves useful to you and let me know if there’s anything you’d like to see added to it. Download the latest version from: &lt;a title="http://cid-550f681dad532637.skydrive.live.com/self.aspx/Public/BlogShare/20091105/SSISPackageStatsCollector%5E_v2.sql" href="http://cid-550f681dad532637.skydrive.live.com/self.aspx/Public/BlogShare/20091105/SSISPackageStatsCollector%5E_v2.sql"&gt;http://cid-550f681dad532637.skydrive.live.com/self.aspx/Public/BlogShare/20091105/SSISPackageStatsCollector%5E_v2.sql&lt;/a&gt;. I have also dropped it into &lt;a href="http://consultingblogs.emc.com/jamiethomson/archive/tags/sqlmesh/default.aspx"&gt;SQLMesh&lt;/a&gt;.&lt;/p&gt;  &lt;p&gt;Looking forward to some feedback (hint hint).&lt;/p&gt;  &lt;p&gt;&lt;a href="http://twitter.com/jamiet"&gt;@Jamiet&lt;/a&gt;&lt;/p&gt;&lt;img src="http://sqlblog.com/aggbug.aspx?PostID=18599" width="1" height="1"&gt;</description><category domain="http://sqlblog.com/blogs/jamie_thomson/archive/tags/nugget/default.aspx">nugget</category><category domain="http://sqlblog.com/blogs/jamie_thomson/archive/tags/sql+server+integration+services/default.aspx">sql server integration services</category><category domain="http://sqlblog.com/blogs/jamie_thomson/archive/tags/ssis/default.aspx">ssis</category><category domain="http://sqlblog.com/blogs/jamie_thomson/archive/tags/SSISPackageStatsCollector/default.aspx">SSISPackageStatsCollector</category><category domain="http://sqlblog.com/blogs/jamie_thomson/archive/tags/t-sql/default.aspx">t-sql</category><category domain="http://sqlblog.com/blogs/jamie_thomson/archive/tags/XML/default.aspx">XML</category><category domain="http://sqlblog.com/blogs/jamie_thomson/archive/tags/XPath/default.aspx">XPath</category><category domain="http://sqlblog.com/blogs/jamie_thomson/archive/tags/xquery/default.aspx">xquery</category></item><item><title>Collecting information about your SSIS packages [SSIS Nugget]</title><link>http://sqlblog.com/blogs/jamie_thomson/archive/2009/10/18/collecting-information-about-your-ssis-packages-ssis-nugget.aspx</link><pubDate>Sun, 18 Oct 2009 21:08:00 GMT</pubDate><guid isPermaLink="false">21093a07-8b3d-42db-8cbf-3350fcbf5496:17904</guid><dc:creator>jamiet</dc:creator><slash:comments>32</slash:comments><comments>http://sqlblog.com/blogs/jamie_thomson/comments/17904.aspx</comments><wfw:commentRss>http://sqlblog.com/blogs/jamie_thomson/commentrss.aspx?PostID=17904</wfw:commentRss><wfw:comment>http://sqlblog.com/blogs/jamie_thomson/rsscomments.aspx?PostID=17904</wfw:comment><description>&lt;p&gt;Did you know that is is possible to read the contents of a SSIS package (i.e. a .dtsx file) from within SQL Server Management Studio (SSMS) using T-SQL? For example, take the following T-SQL snippet:&lt;/p&gt;
&lt;div id="codeSnippetWrapper"&gt;&lt;pre style="BORDER-BOTTOM-STYLE:none;TEXT-ALIGN:left;PADDING-BOTTOM:0px;LINE-HEIGHT:12pt;BORDER-RIGHT-STYLE:none;BACKGROUND-COLOR:#f4f4f4;MARGIN:0em;PADDING-LEFT:0px;WIDTH:100%;PADDING-RIGHT:0px;FONT-FAMILY:'Courier New', courier, monospace;DIRECTION:ltr;BORDER-TOP-STYLE:none;COLOR:black;FONT-SIZE:8pt;BORDER-LEFT-STYLE:none;OVERFLOW:visible;PADDING-TOP:0px;" id="codeSnippet"&gt;&lt;span style="COLOR:#0000ff;"&gt;select&lt;/span&gt;    &lt;span style="COLOR:#0000ff;"&gt;cast&lt;/span&gt;(BulkColumn &lt;span style="COLOR:#0000ff;"&gt;as&lt;/span&gt; XML)&lt;br&gt;&lt;span style="COLOR:#0000ff;"&gt;from&lt;/span&gt;    &lt;span style="COLOR:#0000ff;"&gt;openrowset&lt;/span&gt;(&lt;span style="COLOR:#0000ff;"&gt;bulk&lt;/span&gt; &lt;span style="COLOR:#006080;"&gt;'C:\tmp\MyPkg.dtsx'&lt;/span&gt;,&lt;br&gt;                        single_blob) &lt;span style="COLOR:#0000ff;"&gt;as&lt;/span&gt; pkgColumn;&lt;/pre&gt;&lt;br&gt;&lt;/div&gt;
&lt;p&gt;It uses &lt;a href="http://msdn.microsoft.com/en-us/library/ms190312.aspx"&gt;OPENROWSET&lt;/a&gt; to return the contents of a specified package (&lt;font face="Courier New"&gt;C:\tmp\MyPkg.dtsx&lt;/font&gt;) as an XML document. Here is a screenshot showing what this returns:&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;&lt;a href="http://sqlblog.com/blogs/jamie_thomson/image_597DE8D8.png"&gt;&lt;img src="http://sqlblog.com/blogs/jamie_thomson/image_thumb_38AC90D5.png" style="BORDER-RIGHT-WIDTH:0px;DISPLAY:inline;BORDER-TOP-WIDTH:0px;BORDER-BOTTOM-WIDTH:0px;BORDER-LEFT-WIDTH:0px;" title="dtsx package XML ssis" alt="dtsx package XML ssis" height="81" width="353" border="0"&gt;&lt;/a&gt; &lt;/p&gt;&lt;/blockquote&gt;
&lt;p&gt;and clicking on that result opens up the following:&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;&lt;a href="http://sqlblog.com/blogs/jamie_thomson/image_70F0294F.png"&gt;&lt;img src="http://sqlblog.com/blogs/jamie_thomson/image_thumb_5D8A05B4.png" style="BORDER-RIGHT-WIDTH:0px;DISPLAY:inline;BORDER-TOP-WIDTH:0px;BORDER-BOTTOM-WIDTH:0px;BORDER-LEFT-WIDTH:0px;" title="dts package xml screenshot ssis" alt="dts package xml screenshot ssis" height="291" width="802" border="0"&gt;&lt;/a&gt; &lt;/p&gt;&lt;/blockquote&gt;
&lt;p&gt;That’s what the inards of a .dtsx file look like. In other words we now have a queryable XML document representing a package, thereafter you’re limited only to what you can do with XQuery which is quite a lot. Now, I’m no XQuery expert by any means but I did manage to find a few uses for this. Here are some sample queries:&lt;/p&gt;
&lt;h3&gt;All properties of a package&lt;/h3&gt;
&lt;div&gt;&lt;pre style="BORDER-BOTTOM-STYLE:none;TEXT-ALIGN:left;PADDING-BOTTOM:0px;LINE-HEIGHT:12pt;BORDER-RIGHT-STYLE:none;BACKGROUND-COLOR:#f4f4f4;MARGIN:0em;PADDING-LEFT:0px;WIDTH:100%;PADDING-RIGHT:0px;FONT-FAMILY:'Courier New', courier, monospace;DIRECTION:ltr;BORDER-TOP-STYLE:none;COLOR:black;FONT-SIZE:8pt;BORDER-LEFT-STYLE:none;OVERFLOW:visible;PADDING-TOP:0px;" id="codeSnippet"&gt;&lt;span style="COLOR:#0000ff;"&gt;SELECT&lt;/span&gt;    Props.Prop.query(&lt;span style="COLOR:#006080;"&gt;'.'&lt;/span&gt;)                                                        &lt;span style="COLOR:#0000ff;"&gt;as&lt;/span&gt; PropXml&lt;br&gt;,        Props.Prop.&lt;span style="COLOR:#0000ff;"&gt;value&lt;/span&gt;(&lt;span style="COLOR:#006080;"&gt;'declare namespace p1="www.microsoft.com/SqlServer/Dts";&lt;br&gt;                            string(./@p1:Name)'&lt;/span&gt;,&lt;span style="COLOR:#006080;"&gt;'nvarchar(max)'&lt;/span&gt;)                    &lt;span style="COLOR:#0000ff;"&gt;as&lt;/span&gt; PropName&lt;br&gt;,        Props.Prop.&lt;span style="COLOR:#0000ff;"&gt;value&lt;/span&gt;(&lt;span style="COLOR:#006080;"&gt;'.'&lt;/span&gt;, &lt;span style="COLOR:#006080;"&gt;'nvarchar(max)'&lt;/span&gt;)                                        &lt;span style="COLOR:#0000ff;"&gt;as&lt;/span&gt; PropValue&lt;br&gt;&lt;span style="COLOR:#0000ff;"&gt;FROM&lt;/span&gt;    (&lt;br&gt;        &lt;span style="COLOR:#0000ff;"&gt;SELECT&lt;/span&gt;    &lt;span style="COLOR:#0000ff;"&gt;CAST&lt;/span&gt;(pkgblob.BulkColumn &lt;span style="COLOR:#0000ff;"&gt;AS&lt;/span&gt; XML) pkgXML&lt;br&gt;        &lt;span style="COLOR:#0000ff;"&gt;FROM&lt;/span&gt;    &lt;span style="COLOR:#0000ff;"&gt;OPENROWSET&lt;/span&gt;(&lt;span style="COLOR:#0000ff;"&gt;bulk&lt;/span&gt; &lt;span style="COLOR:#006080;"&gt;'C:\tmp\MyPkg.dtsx'&lt;/span&gt;,single_blob) &lt;span style="COLOR:#0000ff;"&gt;AS&lt;/span&gt; pkgblob&lt;br&gt;        ) t&lt;br&gt;&lt;span style="COLOR:#0000ff;"&gt;CROSS&lt;/span&gt;    APPLY pkgXML.nodes(&lt;span style="COLOR:#006080;"&gt;'declare namespace DTS="www.microsoft.com/SqlServer/Dts";&lt;br&gt;                        /DTS:Executable/DTS:Property'&lt;/span&gt;) Props(Prop)&lt;br&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;div&gt;&amp;nbsp;&lt;/div&gt;
&lt;blockquote&gt;
&lt;div&gt;&lt;a href="http://sqlblog.com/blogs/jamie_thomson/image_172F3050.png"&gt;&lt;img src="http://sqlblog.com/blogs/jamie_thomson/image_thumb_22EEBA46.png" style="BORDER-RIGHT-WIDTH:0px;DISPLAY:inline;BORDER-TOP-WIDTH:0px;BORDER-BOTTOM-WIDTH:0px;BORDER-LEFT-WIDTH:0px;" title="dtsx properties xml ssis" alt="dtsx properties xml ssis" height="207" width="820" border="0"&gt;&lt;/a&gt; &lt;/div&gt;&lt;/blockquote&gt;
&lt;div&gt;&lt;i&gt;I had &lt;a href="http://social.msdn.microsoft.com/Forums/en-US/sqlxml/thread/871099bf-532a-4eab-b8ed-f96d701fe6da"&gt;a lot of help&lt;/a&gt; from &lt;/i&gt;&lt;a href="http://twitter.com/rbarryyoung"&gt;&lt;i&gt;@rbarryyoung&lt;/i&gt;&lt;/a&gt;&lt;i&gt; with this one!&lt;/i&gt;&lt;/div&gt;
&lt;div&gt;&amp;nbsp;&lt;/div&gt;
&lt;h3&gt;Name and type of every task in a package&lt;/h3&gt;
&lt;div id="codeSnippetWrapper"&gt;&lt;pre style="BORDER-BOTTOM-STYLE:none;TEXT-ALIGN:left;PADDING-BOTTOM:0px;LINE-HEIGHT:12pt;BORDER-RIGHT-STYLE:none;BACKGROUND-COLOR:#f4f4f4;MARGIN:0em;PADDING-LEFT:0px;WIDTH:100%;PADDING-RIGHT:0px;FONT-FAMILY:'Courier New', courier, monospace;DIRECTION:ltr;BORDER-TOP-STYLE:none;COLOR:black;FONT-SIZE:8pt;BORDER-LEFT-STYLE:none;OVERFLOW:visible;PADDING-TOP:0px;" id="codeSnippet"&gt;&lt;span style="COLOR:#0000ff;"&gt;SELECT&lt;/span&gt;    Pkg.props.&lt;span style="COLOR:#0000ff;"&gt;value&lt;/span&gt;(&lt;span style="COLOR:#006080;"&gt;'declare namespace p1="www.microsoft.com/SqlServer/Dts";&lt;br&gt;                            ./p1:Property[@p1:Name='&lt;/span&gt;&lt;span style="COLOR:#006080;"&gt;'ObjectName'&lt;/span&gt;&lt;span style="COLOR:#006080;"&gt;'][1]'&lt;/span&gt;,&lt;span style="COLOR:#006080;"&gt;'nvarchar(max)'&lt;/span&gt;) &lt;span style="COLOR:#0000ff;"&gt;as&lt;/span&gt; TaskName&lt;br&gt;,        Pkg.props.&lt;span style="COLOR:#0000ff;"&gt;value&lt;/span&gt;(&lt;span style="COLOR:#006080;"&gt;'declare namespace p1="www.microsoft.com/SqlServer/Dts";&lt;br&gt;                            ./@p1:ExecutableType'&lt;/span&gt;,&lt;span style="COLOR:#006080;"&gt;'nvarchar(max)'&lt;/span&gt;) &lt;span style="COLOR:#0000ff;"&gt;as&lt;/span&gt; TaskType&lt;br&gt;&lt;span style="COLOR:#0000ff;"&gt;FROM&lt;/span&gt;    (&lt;br&gt;        &lt;span style="COLOR:#0000ff;"&gt;select&lt;/span&gt;    &lt;span style="COLOR:#0000ff;"&gt;cast&lt;/span&gt;(pkgblob.BulkColumn &lt;span style="COLOR:#0000ff;"&gt;as&lt;/span&gt; XML) pkgXML&lt;br&gt;        &lt;span style="COLOR:#0000ff;"&gt;from&lt;/span&gt;    &lt;span style="COLOR:#0000ff;"&gt;openrowset&lt;/span&gt;(&lt;span style="COLOR:#0000ff;"&gt;bulk&lt;/span&gt; &lt;span style="COLOR:#006080;"&gt;'C:\tmp\Package.dtsx'&lt;/span&gt;,single_blob) &lt;span style="COLOR:#0000ff;"&gt;as&lt;/span&gt; pkgblob&lt;br&gt;        ) t&lt;br&gt;&lt;span style="COLOR:#0000ff;"&gt;CROSS&lt;/span&gt;    APPLY pkgXML.nodes(&lt;span style="COLOR:#006080;"&gt;'declare namespace DTS="www.microsoft.com/SqlServer/Dts";&lt;br&gt;                            //DTS:Executable[@DTS:ExecutableType!='&lt;/span&gt;&lt;span style="COLOR:#006080;"&gt;'STOCK:SEQUENCE'&lt;/span&gt;&lt;span style="COLOR:#006080;"&gt;'&lt;br&gt;                        and    @DTS:ExecutableType!='&lt;/span&gt;&lt;span style="COLOR:#006080;"&gt;'STOCK:FORLOOP'&lt;/span&gt;&lt;span style="COLOR:#006080;"&gt;'&lt;br&gt;                        and    @DTS:ExecutableType!='&lt;/span&gt;&lt;span style="COLOR:#006080;"&gt;'STOCK:FOREACHLOOP'&lt;/span&gt;&lt;span style="COLOR:#006080;"&gt;'&lt;br&gt;                        and not(contains(@DTS:ExecutableType,'&lt;/span&gt;&lt;span style="COLOR:#006080;"&gt;'.Package.'&lt;/span&gt;&lt;span style="COLOR:#006080;"&gt;'))]'&lt;/span&gt;) Pkg(props)&lt;/pre&gt;&lt;br&gt;&lt;/div&gt;
&lt;blockquote&gt;
&lt;div&gt;&lt;a href="http://sqlblog.com/blogs/jamie_thomson/image_004D0C7C.png"&gt;&lt;img src="http://sqlblog.com/blogs/jamie_thomson/image_thumb_38A87CD6.png" style="BORDER-RIGHT-WIDTH:0px;DISPLAY:inline;BORDER-TOP-WIDTH:0px;BORDER-BOTTOM-WIDTH:0px;BORDER-LEFT-WIDTH:0px;" title="All tasks in a dtsx package file" alt="All tasks in a dtsx package file" height="232" width="524" border="0"&gt;&lt;/a&gt; &lt;/div&gt;&lt;/blockquote&gt;
&lt;div&gt;&lt;i&gt;Note that this one will also return all tasks that exist in eventhandlers and it ignores how “deep” a task is in the &lt;a href="http://consultingblogs.emc.com/jamiethomson/archive/2004/12/13/445.aspx"&gt;container hierarchy&lt;/a&gt;.&lt;/i&gt;&lt;/div&gt;
&lt;div&gt;&amp;nbsp;&lt;/div&gt;
&lt;h3&gt;Putting it all together&lt;/h3&gt;
&lt;div&gt;Ok, that’s all pretty cool but it would be nice to combine it all together and get a summary of many packages, perhaps all of the packages on your machine. Hence I’ve put together a T-SQL script that will display summary information about all of the packages in a folder and its subfolders. Here’s the results of running that script on my dev machine:&lt;/div&gt;
&lt;div&gt;&amp;nbsp;&lt;/div&gt;
&lt;div&gt;&lt;a href="http://sqlblog.com/blogs/jamie_thomson/image_43BCBFF1.png"&gt;&lt;img src="http://sqlblog.com/blogs/jamie_thomson/image_thumb_082C1557.png" style="BORDER-BOTTOM:0px;BORDER-LEFT:0px;DISPLAY:inline;BORDER-TOP:0px;BORDER-RIGHT:0px;" title="ssis package statistics information" alt="ssis package statistics information" height="253" width="875" border="0"&gt;&lt;/a&gt; &lt;/div&gt;
&lt;div&gt;&lt;br&gt;&lt;/div&gt;
&lt;div&gt;217 packages – I’ve collected lot of them over the years! This shows a sampling of some of the information that it is possible to collect:&lt;/div&gt;
&lt;ul&gt;
&lt;li&gt;Package name &lt;/li&gt;
&lt;li&gt;Original creator of the package &lt;/li&gt;
&lt;li&gt;Package Type (signifies which version of BIDS was used to originally build it) &lt;/li&gt;
&lt;li&gt;Version numbers &lt;/li&gt;
&lt;li&gt;Number of tasks in the package &lt;/li&gt;&lt;/ul&gt;
&lt;div&gt;Want to know what your most complex package might be? Simply order this dataset in descending order of [NumberOfTasks]. Or maybe you want to know which of your developers has built the most packages – the answers are right here!&lt;/div&gt;
&lt;div&gt;&amp;nbsp;&lt;/div&gt;
&lt;div&gt;Of course, this could be extended to capture much much more information than what I have captured here. You may want to know how many eventhandlers each of your packages has, when the packages were created, or perhaps how many components are in your dataflows. The (SSIS) world is your oyster!!!&lt;/div&gt;
&lt;div&gt;&amp;nbsp;&lt;/div&gt;
&lt;div&gt;One thing that I thought would be &lt;i&gt;very&lt;/i&gt; useful would be to stick this script into a SQL Agent job, run it on a daily basis, and insert the results into a history table thereby giving you a running history of all the packages in your system and when they changed. If anyone does do that let me know how it goes!&lt;/div&gt;
&lt;div&gt;&amp;nbsp;&lt;/div&gt;
&lt;div&gt;To execute the script simply open it and change the following line as appropriate:&lt;/div&gt;
&lt;div id="codeSnippetWrapper"&gt;
&lt;blockquote&gt;&lt;pre style="BORDER-BOTTOM-STYLE:none;TEXT-ALIGN:left;PADDING-BOTTOM:0px;LINE-HEIGHT:12pt;BORDER-RIGHT-STYLE:none;BACKGROUND-COLOR:#f4f4f4;MARGIN:0em;PADDING-LEFT:0px;WIDTH:100%;PADDING-RIGHT:0px;FONT-FAMILY:'Courier New', courier, monospace;DIRECTION:ltr;BORDER-TOP-STYLE:none;COLOR:black;FONT-SIZE:8pt;BORDER-LEFT-STYLE:none;OVERFLOW:visible;PADDING-TOP:0px;" id="codeSnippet"&gt;&lt;span style="COLOR:#0000ff;"&gt;DECLARE&lt;/span&gt;    @&lt;span style="COLOR:#0000ff;"&gt;Path&lt;/span&gt;    &lt;span style="COLOR:#0000ff;"&gt;VARCHAR&lt;/span&gt;(2000) = &lt;span style="COLOR:#006080;"&gt;'C:\*.dtsx'&lt;/span&gt;;&lt;/pre&gt;&lt;/blockquote&gt;&lt;/div&gt;
&lt;div&gt;Note that you will need to enable [xp_cmdshell] in order to run the script which&amp;nbsp; is available on my SkyDrive at:&lt;/div&gt;
&lt;div&gt;&lt;a href="http://cid-550f681dad532637.skydrive.live.com/self.aspx/Public/BlogShare/20091018/SSISPackageStatsCollector.sql" title="http://cid-550f681dad532637.skydrive.live.com/self.aspx/Public/BlogShare/20091018/SSISPackageStatsCollector.sql"&gt;http://cid-550f681dad532637.skydrive.live.com/self.aspx/Public/BlogShare/20091018/SSISPackageStatsCollector.sql&lt;/a&gt;&lt;/div&gt;
&lt;div&gt;&amp;nbsp;&lt;/div&gt;
&lt;div&gt;If you experience any problems with it let me know. If you adapt it any way let me know that too because writing these XQuery statements is no easy task (believe me!!!) and it would be great to share that stuff with other people!&lt;/div&gt;
&lt;p&gt;&lt;a href="http://twitter.com/jamiet"&gt;@JamieT&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;Update: The original version of this script only worked on SQL Server 2008. I have now updated it so that it works on SQL2005 also! Thanks to Bruce in the comments for alerting me to this fact/&lt;/p&gt;
&lt;p&gt;Update 2: Found a few more issues and hence have uploaded another new version (same link still works though). Changes:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Script will now work on a server with a case-sensitive collation&lt;/li&gt;
&lt;li&gt;xp_cmdshell is turned on at the top of the script&lt;/li&gt;
&lt;li&gt;An error message that could get returned by the command-line call under certain circumstances wasn't getting handled. It is now!&lt;/li&gt;&lt;/ul&gt;Update 3: An updated version with bug fixes and new features is now available at &lt;a href="http://sqlblog.com/blogs/jamie_thomson/archive/2009/11/07/ssis-package-stats-collector-version-2.aspx"&gt;SSIS Package Stats Collector version 2
		
	&lt;/a&gt;&lt;img src="http://sqlblog.com/aggbug.aspx?PostID=17904" width="1" height="1"&gt;</description><category domain="http://sqlblog.com/blogs/jamie_thomson/archive/tags/nugget/default.aspx">nugget</category><category domain="http://sqlblog.com/blogs/jamie_thomson/archive/tags/sql+server+integration+services/default.aspx">sql server integration services</category><category domain="http://sqlblog.com/blogs/jamie_thomson/archive/tags/ssis/default.aspx">ssis</category><category domain="http://sqlblog.com/blogs/jamie_thomson/archive/tags/SSISPackageStatsCollector/default.aspx">SSISPackageStatsCollector</category><category domain="http://sqlblog.com/blogs/jamie_thomson/archive/tags/t-sql/default.aspx">t-sql</category><category domain="http://sqlblog.com/blogs/jamie_thomson/archive/tags/XML/default.aspx">XML</category><category domain="http://sqlblog.com/blogs/jamie_thomson/archive/tags/XPath/default.aspx">XPath</category><category domain="http://sqlblog.com/blogs/jamie_thomson/archive/tags/xquery/default.aspx">xquery</category></item><item><title>Things you might not know about Precedence Constraints : SSIS Nugget</title><link>http://sqlblog.com/blogs/jamie_thomson/archive/2009/10/11/things-you-might-not-know-about-precedence-constraints-ssis.aspx</link><pubDate>Sat, 10 Oct 2009 22:11:06 GMT</pubDate><guid isPermaLink="false">21093a07-8b3d-42db-8cbf-3350fcbf5496:17540</guid><dc:creator>jamiet</dc:creator><slash:comments>15</slash:comments><comments>http://sqlblog.com/blogs/jamie_thomson/comments/17540.aspx</comments><wfw:commentRss>http://sqlblog.com/blogs/jamie_thomson/commentrss.aspx?PostID=17540</wfw:commentRss><wfw:comment>http://sqlblog.com/blogs/jamie_thomson/rsscomments.aspx?PostID=17540</wfw:comment><description>&lt;p&gt;Precedence constraints are one of the most oft used features of SQL Server Integration Services (SSIS) but also often one of the most overlooked. In this blog post I’ll cover a couple of things that you might not know about them.&lt;/p&gt;  &lt;h3&gt;The basics&lt;/h3&gt;  &lt;p&gt;Most people typically use precedence constraints like this, with a green arrow:&lt;/p&gt;  &lt;blockquote&gt;   &lt;p&gt;&lt;a href="http://sqlblog.com/blogs/jamie_thomson/image_633958E5.png"&gt;&lt;img style="border-bottom:0px;border-left:0px;display:inline;border-top:0px;border-right:0px;" title="image" border="0" alt="image" src="http://sqlblog.com/blogs/jamie_thomson/image_thumb_67CF639F.png" width="186" height="217" /&gt;&lt;/a&gt; &lt;/p&gt; &lt;/blockquote&gt;  &lt;p&gt;A green arrow here means “If ‘SEQ 1’ succeeds, execute ‘SEQ 2’”; that’s called on OnSuccess constraint. Like the DTS of old there are also OnError (Red) and OnCompletion (Blue) constraints which behave exactly as you would expect.&lt;/p&gt;  &lt;p&gt;In SSIS you can also make precedence constraints conditional, so you could have an expression that states “Execute ‘SEQ 2’ &lt;em&gt;IF&lt;/em&gt; ‘SEQ 1” is successful &lt;em&gt;AND&lt;/em&gt; some condition is true as well”.&lt;/p&gt;  &lt;p&gt;I’m sure most of you knew all that already, so here are a few things that you might not know.&lt;/p&gt;  &lt;h3&gt;Annotated Precedence Constraints&lt;/h3&gt;  &lt;p&gt;Firstly, did you know that precedence constraints can be annotated with the expression that is placed upon that precedence constraint? Each precedence constraint has a property called ‘ShowAnnotation’ and it has 5 possible values as depicted here:&lt;/p&gt;  &lt;blockquote&gt;   &lt;p&gt;&lt;a href="http://sqlblog.com/blogs/jamie_thomson/image_11CF61C8.png"&gt;&lt;img style="border-bottom:0px;border-left:0px;display:inline;border-top:0px;border-right:0px;" title="image" border="0" alt="image" src="http://sqlblog.com/blogs/jamie_thomson/image_thumb_3E781BA1.png" width="414" height="173" /&gt;&lt;/a&gt; &lt;/p&gt; &lt;/blockquote&gt;  &lt;p&gt;Most of those options aren’t very useful but one of them, ‘Constraint Options’, can be very useful indeed if you have an expression on your constraint because it causes the expression to be displayed on your design surface like so:&lt;/p&gt;  &lt;blockquote&gt;   &lt;p&gt;&lt;a href="http://sqlblog.com/blogs/jamie_thomson/image_0F46300A.png"&gt;&lt;img style="border-bottom:0px;border-left:0px;display:inline;border-top:0px;border-right:0px;" title="precedence constraint showannotation options" border="0" alt="precedence constraint showannotation options" src="http://sqlblog.com/blogs/jamie_thomson/image_thumb_0E01972B.png" width="407" height="225" /&gt;&lt;/a&gt; &lt;/p&gt; &lt;/blockquote&gt;  &lt;p&gt;Pretty neat! I am very much a fan of self-documenting packages and this is clearly a nod in that direction. I wish this were the default setting for this property but unfortunately it is not.&lt;/p&gt;  &lt;h3&gt;Precedence Constraint Scope&lt;/h3&gt;  &lt;p&gt;&lt;a href="http://consultingblogs.emc.com/jamiethomson/archive/2004/12/13/445.aspx"&gt;SSIS’s container hierarchy&lt;/a&gt; gives rise to the notion of scope. We are used to applying scope to a variable but its worth remembering that precedence constraints have scope as well. In the same way that every &lt;a href="http://msdn.microsoft.com/en-us/library/microsoft.sqlserver.dts.runtime.dtscontainer_members.aspx"&gt;container&lt;/a&gt;* has &lt;a href="http://msdn.microsoft.com/en-us/library/microsoft.sqlserver.dts.runtime.dtscontainer.variables.aspx"&gt;a collection of variables&lt;/a&gt;, every &lt;a href="http://msdn.microsoft.com/en-us/library/microsoft.sqlserver.dts.runtime.sequence_members.aspx"&gt;sequence container&lt;/a&gt;, &lt;a href="http://msdn.microsoft.com/en-us/library/microsoft.sqlserver.dts.runtime.forloop_members.aspx"&gt;for loop container&lt;/a&gt;, &lt;a href="http://msdn.microsoft.com/en-us/library/microsoft.sqlserver.dts.runtime.foreachloop_members.aspx"&gt;for each loop container&lt;/a&gt;, &lt;a href="http://msdn.microsoft.com/en-us/library/microsoft.sqlserver.dts.runtime.dtseventhandler_members.aspx"&gt;eventhandler container&lt;/a&gt; and &lt;a href="http://msdn.microsoft.com/en-us/library/microsoft.sqlserver.dts.runtime.package_members.aspx"&gt;package container&lt;/a&gt; also has a &lt;a href="http://msdn.microsoft.com/en-us/library/microsoft.sqlserver.dts.runtime.package.precedenceconstraints.aspx"&gt;collection of precedence constraints&lt;/a&gt; as is illustrated in this screenshot from MSDN:&lt;/p&gt;  &lt;blockquote&gt;   &lt;p&gt;&lt;a href="http://sqlblog.com/blogs/jamie_thomson/image_3AAA5104.png"&gt;&lt;img style="border-bottom:0px;border-left:0px;display:inline;border-top:0px;border-right:0px;" title="image" border="0" alt="image" src="http://sqlblog.com/blogs/jamie_thomson/image_thumb_412DAAC7.png" width="644" height="316" /&gt;&lt;/a&gt; &lt;/p&gt;    &lt;p&gt;&lt;a href="http://msdn.microsoft.com/en-us/library/microsoft.sqlserver.dts.runtime.sequence_members.aspx"&gt;Sequence Members&lt;/a&gt; (&lt;a title="http://msdn.microsoft.com/en-us/library/microsoft.sqlserver.dts.runtime.sequence_members.aspx" href="http://msdn.microsoft.com/en-us/library/microsoft.sqlserver.dts.runtime.sequence_members.aspx"&gt;http://msdn.microsoft.com/en-us/library/microsoft.sqlserver.dts.runtime.sequence_members.aspx&lt;/a&gt;)&lt;/p&gt; &lt;/blockquote&gt;  &lt;p&gt;&lt;em&gt;*Remember, every task, eventhandler and package is also a container&lt;/em&gt;&lt;/p&gt;  &lt;p&gt;Why is this important? Well, it means that every variable referenced in a precedence constraint &lt;em&gt;must&lt;/em&gt; be scoped to the container of which the precedence constraint is a member (that’s a bit of a mouthful but read it bit by bit and hopefully it will make sense).&lt;/p&gt;  &lt;p&gt;This is worth remembering because there is a bug in the SSIS Package Designer in BIDS which manifests itself as you not getting a design-time error if a variable in your precedence constraint expression is scoped to the container that the precedence constraint is coming &lt;em&gt;from&lt;/em&gt;. Phew another mouthful, let me explain by referring to a picture. &lt;/p&gt;  &lt;blockquote&gt;   &lt;p&gt;&lt;a href="http://sqlblog.com/blogs/jamie_thomson/image_03709D3E.png"&gt;&lt;img style="border-bottom:0px;border-left:0px;display:inline;border-top:0px;border-right:0px;" title="image" border="0" alt="image" src="http://sqlblog.com/blogs/jamie_thomson/image_thumb_4915275C.png" width="358" height="294" /&gt;&lt;/a&gt; &lt;/p&gt; &lt;/blockquote&gt;  &lt;p&gt;In this example if the variable @[User::NumberOfRows] were scoped to task “SQL Prepare some data” you would not get a design-time error but you definitely &lt;em&gt;would &lt;/em&gt;get an error when you executed the package. The bug is at design-time, not execution-time.&lt;/p&gt;  &lt;h3&gt;Wrap-up&lt;/h3&gt;  &lt;p&gt;Ok, there’s nothing here that is particularly earth-shattering but I think it helps to know this stuff. If you have any comments or questions please post them below.&lt;/p&gt;  &lt;p&gt;&lt;a href="http://twitter.com/jamiet"&gt;@JamieT&lt;/a&gt;&lt;/p&gt;&lt;img src="http://sqlblog.com/aggbug.aspx?PostID=17540" width="1" height="1"&gt;</description><category domain="http://sqlblog.com/blogs/jamie_thomson/archive/tags/nugget/default.aspx">nugget</category><category domain="http://sqlblog.com/blogs/jamie_thomson/archive/tags/precedence+constraints/default.aspx">precedence constraints</category><category domain="http://sqlblog.com/blogs/jamie_thomson/archive/tags/sql+server/default.aspx">sql server</category><category domain="http://sqlblog.com/blogs/jamie_thomson/archive/tags/sql+server+integration+services/default.aspx">sql server integration services</category><category domain="http://sqlblog.com/blogs/jamie_thomson/archive/tags/ssis/default.aspx">ssis</category></item></channel></rss>