Reputation: 21
I have a variable "variable1" defined with SSIS expression as its value. Is there a way to evaluate the "variable1" as expression in a second variable "variable2"?
For example, variable1 is as below:
When I evaluate variable2 by adding the variable1 in the expression builder, I see the same value of variable1.
Is there a way to get the variable2 to evaluate the expression "YEAR(GETDATE())" and give the result (2022) as its value?
Upvotes: 0
Views: 216
Reputation: 153
Because YEAR(GETDATE())
is being saved as a string value directly inside of User::variable1, the expression builder does not recognize that you are trying to obtain the evaluation of this statement; it thinks you are wanting it to be passed directly as a string.
YEAR(GETDATE())
would first need to be used in the expression field for User::variable1, and once it is updated there you should see the expected result when using @[User::variable1].
However, one problem remains--because User::variable1 is a string and the YEAR() function returns an integer value, you would first need to convert the result from an integer to a string. You could do this by setting this value into the expression field for User::variable1:
(DT_WSTR, 5) YEAR(GETDATE())
Upvotes: 0