SQL Server Developer Center >
SQL Server Forums
>
SQL Server Integration Services
>
Set variable value
Set variable value
- Hi,
How can i set a variables's value (string) in my flow? When a lookup isn't found for example i want to assign a value to the variable so that the application (.net) that runs the package can read that value.
Thanks
Answers
- Use a script component and make the variable as read/write variable.
Then assign the required value by accessing the variable using Me.
Me.variablename = value
Nitesh Rai- Please mark the post as answered if it answers your question- Proposed As Answer byCim Ryan - MSFTMSFT, ModeratorThursday, November 05, 2009 6:41 PM
- Marked As Answer byBob BojanicMSFT, OwnerSaturday, November 14, 2009 1:48 AM
All Replies
You can use Script Task to do it.
Thanks, Bharani M - Please mark the post as answered if it answers your question. - Please vote the post as Helpful if you find the post as helpful.- Edited byBharani 3010 Wednesday, October 28, 2009 10:56 AMremoved the link
Hi,
How can i set a variables's value (string) in my flow? When a lookup isn't found for example i want to assign a value to the variable so that the application (.net) that runs the package can read that value.
Thanks
Hi,
You could use the Row count transform for the lookup failed records in DFT.
Once you come to control flow just check if the count is > 1.
If you want to do something in control flow you can make use of variable expressions or script task to update the variables.
Hope this helps !!
Sudeep | My Blog- I can't see the article that Bharani linked to because it is blocked by my employer for some reason. However, I should point out that you need to put the code into a script component , not a script task . More accurately you need to put it in the PostExecute() method.
I expect that's what the article says - Brian Knight knows his stuff!
http://sqlblog.com/blogs/jamie_thomson/ | http://jamiethomson.spaces.live.com/ | @jamiet - Jamie,
I had removed the link already. This was in my archive. Thanks for pointing out.
Thanks, Bharani M - Please mark the post as answered if it answers your question. - Please vote the post as Helpful if you find the post as helpful. - Hi,
Can you please give me a link to an example that does the above. Couldn't find something.
Thanks Hi,
Can you please give me a link to an example that does the above. Couldn't find something.
Thanks
But it used to work in DTS (7) - Capture a value from inside the data pump into a variable
(http://consultingblogs.emc.com/jamiethomson/archive/2006/07/18/SSIS_3A00_-But-it-used-to-work-in-DTS-_2800_7_2900_-_2D00_-Capture-a-value-from-inside-the-data-pump-into-a-variable.aspx )
Out of interest, what did you search for? Plenty of material here: http://www.bing.com/search?q=ssis+postexecute
http://sqlblog.com/blogs/jamie_thomson/ | http://jamiethomson.spaces.live.com/ | @jamiet- Proposed As Answer byCim Ryan - MSFTMSFT, ModeratorThursday, November 05, 2009 6:41 PM
- Use a script component and make the variable as read/write variable.
Then assign the required value by accessing the variable using Me.
Me.variablename = value
Nitesh Rai- Please mark the post as answered if it answers your question- Proposed As Answer byCim Ryan - MSFTMSFT, ModeratorThursday, November 05, 2009 6:41 PM
- Marked As Answer byBob BojanicMSFT, OwnerSaturday, November 14, 2009 1:48 AM
- Thanks. Nitesh's solution works for me.


