<?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 : synchronous components</title><link>http://sqlblog.com/blogs/jamie_thomson/archive/tags/synchronous+components/default.aspx</link><description>Tags: synchronous components</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/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/dataflow/default.aspx">dataflow</category><category domain="http://sqlblog.com/blogs/jamie_thomson/archive/tags/synchronous+components/default.aspx">synchronous components</category></item></channel></rss>