<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	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/"
		>
<channel>
	<title>Comments on: Initialize SSIS Variables from a Database Table</title>
	<atom:link href="http://blog.boxedbits.com/archives/8/feed" rel="self" type="application/rss+xml" />
	<link>http://blog.boxedbits.com/archives/8</link>
	<description>( ... more specifically about BI with Microsoft products )</description>
	<lastBuildDate>Wed, 01 Feb 2012 21:00:27 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
		<item>
		<title>By: zed</title>
		<link>http://blog.boxedbits.com/archives/8/comment-page-1#comment-3667</link>
		<dc:creator>zed</dc:creator>
		<pubDate>Wed, 01 Feb 2012 21:00:27 +0000</pubDate>
		<guid isPermaLink="false">http://blog.boxedbits.com/archives/8#comment-3667</guid>
		<description>Im also facing: &lt;&gt;
Anyone solved this issue? Thanks</description>
		<content:encoded><![CDATA[<p>Im also facing: &lt;&gt;<br />
Anyone solved this issue? Thanks</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: zed</title>
		<link>http://blog.boxedbits.com/archives/8/comment-page-1#comment-3666</link>
		<dc:creator>zed</dc:creator>
		<pubDate>Wed, 01 Feb 2012 20:58:14 +0000</pubDate>
		<guid isPermaLink="false">http://blog.boxedbits.com/archives/8#comment-3666</guid>
		<description>I also getting dts not declared variable in script task. Anyone solved it?</description>
		<content:encoded><![CDATA[<p>I also getting dts not declared variable in script task. Anyone solved it?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Omar</title>
		<link>http://blog.boxedbits.com/archives/8/comment-page-1#comment-3601</link>
		<dc:creator>Omar</dc:creator>
		<pubDate>Tue, 27 Sep 2011 20:35:29 +0000</pubDate>
		<guid isPermaLink="false">http://blog.boxedbits.com/archives/8#comment-3601</guid>
		<description>Great code, simpler than the others I came across, including MSN&#039;s !
The only problem I had was that the connection is case sensitive!
Omar.</description>
		<content:encoded><![CDATA[<p>Great code, simpler than the others I came across, including MSN&#8217;s !<br />
The only problem I had was that the connection is case sensitive!<br />
Omar.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Marc</title>
		<link>http://blog.boxedbits.com/archives/8/comment-page-1#comment-3600</link>
		<dc:creator>Marc</dc:creator>
		<pubDate>Tue, 27 Sep 2011 17:16:29 +0000</pubDate>
		<guid isPermaLink="false">http://blog.boxedbits.com/archives/8#comment-3600</guid>
		<description>I\&#039;m a rookie in SSIS.

Is it also possible with this script to use mult-value-parameters?

I need to add a condition in a conditional split like \&#039;country in @countries\&#039;.
Should the parametervalue one string like \&#039;UK, Spain, Belgium\&#039;
or should I add a record for each country where the parametername is the same
in every record?

Thanks,

Marc</description>
		<content:encoded><![CDATA[<p>I\&#8217;m a rookie in SSIS.</p>
<p>Is it also possible with this script to use mult-value-parameters?</p>
<p>I need to add a condition in a conditional split like \&#8217;country in @countries\&#8217;.<br />
Should the parametervalue one string like \&#8217;UK, Spain, Belgium\&#8217;<br />
or should I add a record for each country where the parametername is the same<br />
in every record?</p>
<p>Thanks,</p>
<p>Marc</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Sateesh</title>
		<link>http://blog.boxedbits.com/archives/8/comment-page-1#comment-3596</link>
		<dc:creator>Sateesh</dc:creator>
		<pubDate>Sun, 11 Sep 2011 02:54:39 +0000</pubDate>
		<guid isPermaLink="false">http://blog.boxedbits.com/archives/8#comment-3596</guid>
		<description>Hi,
Great Post!!!
i don&#039;t know why i am getting dts is not declared variable in script task.

very glad to guys if you could suggest me something to towards this issue.


Thanks
Sateesh</description>
		<content:encoded><![CDATA[<p>Hi,<br />
Great Post!!!<br />
i don&#8217;t know why i am getting dts is not declared variable in script task.</p>
<p>very glad to guys if you could suggest me something to towards this issue.</p>
<p>Thanks<br />
Sateesh</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Harry Simpson</title>
		<link>http://blog.boxedbits.com/archives/8/comment-page-1#comment-3562</link>
		<dc:creator>Harry Simpson</dc:creator>
		<pubDate>Tue, 01 Mar 2011 17:58:28 +0000</pubDate>
		<guid isPermaLink="false">http://blog.boxedbits.com/archives/8#comment-3562</guid>
		<description>Works great!!  Thanks!!</description>
		<content:encoded><![CDATA[<p>Works great!!  Thanks!!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Bruce Dunwiddie</title>
		<link>http://blog.boxedbits.com/archives/8/comment-page-1#comment-3507</link>
		<dc:creator>Bruce Dunwiddie</dc:creator>
		<pubDate>Wed, 17 Nov 2010 23:53:07 +0000</pubDate>
		<guid isPermaLink="false">http://blog.boxedbits.com/archives/8#comment-3507</guid>
		<description>This will attempt to handle the casting for you from the value retrieved from the database to the correct data type of the variable in the package. So if the value in the database is a numeric stored in a varchar field and the variable data type in the package is an Int32, this will do the parsing and set the variable value successfully.

vars(de.Key).Value = Convert.ChangeType(de.Value, vars(de.Key).DataType)</description>
		<content:encoded><![CDATA[<p>This will attempt to handle the casting for you from the value retrieved from the database to the correct data type of the variable in the package. So if the value in the database is a numeric stored in a varchar field and the variable data type in the package is an Int32, this will do the parsing and set the variable value successfully.</p>
<p>vars(de.Key).Value = Convert.ChangeType(de.Value, vars(de.Key).DataType)</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Robert</title>
		<link>http://blog.boxedbits.com/archives/8/comment-page-1#comment-3456</link>
		<dc:creator>Robert</dc:creator>
		<pubDate>Tue, 23 Mar 2010 10:58:46 +0000</pubDate>
		<guid isPermaLink="false">http://blog.boxedbits.com/archives/8#comment-3456</guid>
		<description>Don&#039;t forget that the Mor% - sorry, the Cre&amp; - sorry, the swell guys at Microsoft managed to localize the name of the default namespace. I&#039;d bet this accounts for at least some of the other commenters&#039; problems.

And by the way, I prefer doing this in a data flow like:
Public Class ScriptMain
    Inherits UserComponent

    Dim oRegEx As Regex

    Public Sub New()
        oRegEx = New Regex(&quot;[^a-zA-Z0-9_]+&quot;)
    End Sub

    Public Overrides Sub Input0_ProcessInputRow(ByVal Row As Input0Buffer)
        Dim iKey As Int32
        Dim sName As String
        Dim vars As IDTSVariables90 = Nothing

        If Not Row.ikey_IsNull AndAlso Not Row.gname_IsNull AndAlso Not Row.tname_IsNull Then
            iKey = CType(Row.ikey, Int32)
            sName = oRegEx.Replace(Row.gname, &quot;_&quot;).Replace(&quot;__&quot;, &quot;_&quot;) &amp; &quot;::&quot; &amp; oRegEx.Replace(Row.tname, &quot;_&quot;).Replace(&quot;__&quot;, &quot;_&quot;)
            Try
                Me.VariableDispenser.LockForWrite(sName)
                Me.VariableDispenser.GetVariables(vars)
            Catch ex As Exception
                Me.ComponentMetaData.FireWarning(1001, &quot;Parameter Reader&quot;, sName &amp; &quot; not found.&quot;, Nothing, 0)
            End Try
            If Not vars Is Nothing Then
                Try
                    vars(sName).Value = iKey
                    Me.ComponentMetaData.IncrementPipelinePerfCounter(103, 1)
                Catch ex As Exception
                End Try
                vars.Unlock()
            End If
        End If
    End Sub

End Class

- Note I thought performance impact of locking/unlocking the vars one by one is negligible, and that this pipeline comes with the fields ikey int, gname wstr and tname wstr, and that I only needed integer parameters in this case.
- Also note the error handling is not clean - am fighting the docs tring to find the specific exception type thrown for a missing name and losing.
- Also note the names in the database are not under my control, hence the sanitizing RegEx.</description>
		<content:encoded><![CDATA[<p>Don&#8217;t forget that the Mor% &#8211; sorry, the Cre&amp; &#8211; sorry, the swell guys at Microsoft managed to localize the name of the default namespace. I&#8217;d bet this accounts for at least some of the other commenters&#8217; problems.</p>
<p>And by the way, I prefer doing this in a data flow like:<br />
Public Class ScriptMain<br />
    Inherits UserComponent</p>
<p>    Dim oRegEx As Regex</p>
<p>    Public Sub New()<br />
        oRegEx = New Regex(&#8220;[^a-zA-Z0-9_]+&#8221;)<br />
    End Sub</p>
<p>    Public Overrides Sub Input0_ProcessInputRow(ByVal Row As Input0Buffer)<br />
        Dim iKey As Int32<br />
        Dim sName As String<br />
        Dim vars As IDTSVariables90 = Nothing</p>
<p>        If Not Row.ikey_IsNull AndAlso Not Row.gname_IsNull AndAlso Not Row.tname_IsNull Then<br />
            iKey = CType(Row.ikey, Int32)<br />
            sName = oRegEx.Replace(Row.gname, &#8220;_&#8221;).Replace(&#8220;__&#8221;, &#8220;_&#8221;) &amp; &#8220;::&#8221; &amp; oRegEx.Replace(Row.tname, &#8220;_&#8221;).Replace(&#8220;__&#8221;, &#8220;_&#8221;)<br />
            Try<br />
                Me.VariableDispenser.LockForWrite(sName)<br />
                Me.VariableDispenser.GetVariables(vars)<br />
            Catch ex As Exception<br />
                Me.ComponentMetaData.FireWarning(1001, &#8220;Parameter Reader&#8221;, sName &amp; &#8221; not found.&#8221;, Nothing, 0)<br />
            End Try<br />
            If Not vars Is Nothing Then<br />
                Try<br />
                    vars(sName).Value = iKey<br />
                    Me.ComponentMetaData.IncrementPipelinePerfCounter(103, 1)<br />
                Catch ex As Exception<br />
                End Try<br />
                vars.Unlock()<br />
            End If<br />
        End If<br />
    End Sub</p>
<p>End Class</p>
<p>- Note I thought performance impact of locking/unlocking the vars one by one is negligible, and that this pipeline comes with the fields ikey int, gname wstr and tname wstr, and that I only needed integer parameters in this case.<br />
- Also note the error handling is not clean &#8211; am fighting the docs tring to find the specific exception type thrown for a missing name and losing.<br />
- Also note the names in the database are not under my control, hence the sanitizing RegEx.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Tom VdP</title>
		<link>http://blog.boxedbits.com/archives/8/comment-page-1#comment-3212</link>
		<dc:creator>Tom VdP</dc:creator>
		<pubDate>Thu, 17 Sep 2009 08:41:12 +0000</pubDate>
		<guid isPermaLink="false">http://blog.boxedbits.com/archives/8#comment-3212</guid>
		<description>Make sure that the variable names in the package and in the table match exactly including casing: if you have a “myVariable” in the table and a “MyVariable” in the package then they will not match.
Also, the Variables collection is empty because you do not supply any variables in the script component’s ReadOnlyVariables or ReadWriteVariables, which is good because the script is supposed to be generic. It looks for any variable defined in the package.</description>
		<content:encoded><![CDATA[<p>Make sure that the variable names in the package and in the table match exactly including casing: if you have a “myVariable” in the table and a “MyVariable” in the package then they will not match.<br />
Also, the Variables collection is empty because you do not supply any variables in the script component’s ReadOnlyVariables or ReadWriteVariables, which is good because the script is supposed to be generic. It looks for any variable defined in the package.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: AK</title>
		<link>http://blog.boxedbits.com/archives/8/comment-page-1#comment-3208</link>
		<dc:creator>AK</dc:creator>
		<pubDate>Wed, 16 Sep 2009 14:11:47 +0000</pubDate>
		<guid isPermaLink="false">http://blog.boxedbits.com/archives/8#comment-3208</guid>
		<description>I tried the samething in my script task. It neither returns any error nor returns desired results. While debugging I found the variables collection count is always getting displayed as 0 inspite of variables declared at the package level scope. Any help will be appreciated.

Thanks,
AK</description>
		<content:encoded><![CDATA[<p>I tried the samething in my script task. It neither returns any error nor returns desired results. While debugging I found the variables collection count is always getting displayed as 0 inspite of variables declared at the package level scope. Any help will be appreciated.</p>
<p>Thanks,<br />
AK</p>
]]></content:encoded>
	</item>
</channel>
</rss>

