There is a 4000-character limit to the DT_WSTR
(Unicode string) data type used by SSIS. Since expressions are converted to DT_WSTR
, they also cannot exceed 4000 characters.
You'll get an error if you exceed the limit at design time. However, you will not receive any obvious warnings or errors if you do so at run time. The operation will fail silently, and the expression may be evaluated incorrectly.
Note: this does not mean that strings or SSIS variables cannot exceed 4000 characters. The limitation only applies to expressions and other places that DT_WSTR is used. For a good explanation of this, take a look at:
http://blogs.conchango.com/jamiethomson/archive/2009/05/27/4000-character-limit-in-ssis.aspx
Here's an example that reproduces the issue:
- Create an SSIS string variable named
testVariable.
- Assign the variable a long value in
a script task (5000 characters, for
instance). The assignment should
succeed.
- Create a second task and connect the
two tasks using a precedence
constraint. Set the evaluation
operation to "Expression" and set
the expression to @testVariable !=
"".
Even though the variable is not empty, the constraint will incorrectly evaluate to False because the expression exceeds 4000 characters. However, this will not cause any errors and the package will not fail.
If you notice strange behavior in your SSIS logic, take a look at your expressions and ensure that they don't exceed 4000 characters when evaluated.