maljee
maljee

Reputation: 21

Can a SSIS variable have a SSIS expression as its value?

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: enter image description here

When I evaluate variable2 by adding the variable1 in the expression builder, I see the same value of variable1. enter image description here

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

Answers (1)

cdbullard
cdbullard

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

Related Questions