How to check existence of string in SSIS Script task

  • Hi

    I need to find the existence of a string, for ex. 'Capex', in a package variable. This I need to do in script task. If the stings is existed in the package I need to set the value of other variable to 1.

    Can any body help in this regard

    Thanks

  • In the Script Task editor, set the package variable that you want to read in the read variables, and the one you want to set to 1 at the write variables.

    In the script, use some code that looks like this:

    If (Dts.Variables("myReadVariable").Value.ToString == "Capex") Then

    Dts.Variables("myWriteVariable").Value = 1

    Endif

    However, I think it is easier to accomplish this by using an expression on the write variable that checks the value of the other variable:

    (User::myReadVariable == "Capex") ? 1 : 0

    Or something like that.

    Don't forget to set the propery EvaluateAsExpression to True of that variable.

    Need an answer? No, you need a question
    My blog at https://sqlkover.com.
    MCSE Business Intelligence - Microsoft Data Platform MVP

Viewing 2 posts - 1 through 1 (of 1 total)

You must be logged in to reply to this topic. Login to reply