SISS Variables -
I have created user defined SSIS variables at the package level.
Example: Here are the varibales
v1 = 10
开发者_如何学运维v2 = 20
v3
The result should be V3 = V1 +V2 Where should i give this expression in the control flow and will i get the result
Please help
Thanks
Am I missing something or is there a reason an expression won't suffice?
Given variables defined as described above
Set "Evaluate as Expression" to True on the variable v3 and for the Expression, use @[User::v1] + @[User::v2] (or click the ellipses and build the expression with the WYSIWYG editor)
If you notice the pink corner of v3, that is due to me running an add-in called BIDSHelper which can assist in your SSIS development tasks but in no way affects the workings of my solution.
You can manipulate variables within a Script Component. If you're using SQL-Server 2005 you get to use VB.Net, if you're using 2008, you have the choice of that or C#.net.
Here are some (VB.net) examples of code I've used to get variables (strings in my case), manipulate them, and send them back to the variable storage area:
Dim logFilename As String
Dim logFilePath As String
' create filename
logFilePath = Dts.Variables("LogFilePath").Value.ToString()
curDate = Now().ToString("yyyyMMdd")
logFilename = "test-" & curDate & ".Log"
Dts.Variables("LogFileName").Value = logFilename
To do the same with your numbers, in the guts of the Script Component (I'm a bit rusty with VB)
Dim v1 as Int
Dim v2 as Int
Dim v3 as Int
// get your variables from the package
v1 = Dts.Variables("v1").Value
v2 = Dts.Varuables("V2").Value
v3 = v1 + v2
// set your result back to the package
Dts.Variables ("v3").Value = v3
精彩评论