<?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>Search results matching tags 'SSIS', 'nugget', and 'sql server'</title><link>http://sqlblog.com/search/SearchResults.aspx?o=DateDescending&amp;tag=SSIS,nugget,sql+server&amp;orTags=0</link><description>Search results matching tags 'SSIS', 'nugget', and 'sql server'</description><dc:language>en-US</dc:language><generator>CommunityServer 2.1 SP2 (Build: 61129.1)</generator><item><title>Things you might not know about Precedence Constraints : SSIS Nugget</title><link>http://sqlblog.com/blogs/jamie_thomson/archive/2009/10/10/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><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;</description></item></channel></rss>