How to: Set the Properties of a Variable

To set the properties of a user-defined variable in Integration Services, you can use one of the following features:

  • The Variables window.

  • The Properties window. The Properties window lists properties for configuring variables that are not available in the Variables window: Description, EvaluateAsExpression, Expression, ReadOnly, and ValueType.

Note

Integration Services also provides a set of system variables whose properties cannot be updated.

Using the Variables Window to Set Properties

To set the properties of a variable by using the Variables window

  1. In Business Intelligence Development Studio, open the Integration Services project that contains the package you want.

  2. In Solution Explorer, right-click the package to open it.

  3. On the SSIS menu, click Variables.

    You can optionally display the Variables window by mapping the View.Variables command to a key combination of your choosing on the Keyboard page of the Options dialog box.

  4. In the Variables window, click Show All Variables.

  5. Optionally, click Choose Variable Columns and in the Choose Variable Columns dialog box, select and clear column options.

  6. Select the variable in the list, and then update values in the Data Type, Value, Namespace, and Raise Change Event columns.

    Note

    Values in the Value column must be compatible with the data type specified in the Data Type column.

  7. To save the updated package, on the File menu, click Save Selected Items.

Using the Properties Window to Set Properties

When you use the Properties window to set the properties of a user defined variable:

  • The value of a variable can be set by the Value or the Expression property. By default, the EvaluateAsExpression property is set to False and the value of the variable is set by the Value property. To use an expression to set the value, you must first set EvaluateAsExpression to True, and then provide an expression in the Expression property. The Value property is automatically set to the evaluation result of the expression.

  • The ValueType property contains the data type of the value in the Value property. When Value is set by an expression, ValueType is automatically updated to a data type that is compatible with the evaluation result of the expression. For example, if Value contains 0 and ValueType property contains Int32 and you then set Expression to GETDATE(), Value contains the current date and time and ValueType is set to DateTime.

  • The Properties window for the variable provides access to the Expression Builder dialog box. You can use this tool to build, validate, and evaluate expressions. For more information, see Expression Builder and Integration Services Expression Reference.

To set the properties of a variable by using the Properties window

  1. In Business Intelligence Development Studio, open the Integration Services project that contains the package you want.

  2. In Solution Explorer, right-click the package to open it.

  3. On the View menu, click Properties Window.

  4. In SSIS Designer, click the Package Explorer tab and expand the Package node.

  5. To modify variables with package scope, expand the Variables node; otherwise, expand the Event Handlers or Executables nodes until you locate the Variables node that contains the variable that you want to modify.

  6. Click the variable whose properties you want to modify.

  7. In the Properties window, update the read/write variable properties. Some properties are read/read only for user-defined variables.

    The following table lists variables that may be updatable.

    Read/write property

    Update action

    Description

    Modify the description.

    EvaluateAsExpression

    Set to True to use the evaluation result of an expression in the Value property.

    Expression

    Click (…) to open the Expression Builder dialog box and build the expression using this graphical tool, or type an expression.

    Name

    For user-defined variables, modify the variable name.

    Namespace

    For user-defined variables, modify the namespace.

    RaiseChangedEvent

    Set to True to raise an event when the variable changes value.

    ReadOnly

    For user-defined variables, set to True to make the variable read/write.

    Value

    For user-defined variables, specify a value. The value must be compatible with value type in the ValueType property.

    ValueType

    For user-defined variables, specify the data type of the variable value.

    Important

    The values of the Name and Namespace properties must begin with an alphabetic character letter as defined by the Unicode Standard 2.0, or an underscore (_). Subsequent characters can be letters or numbers as defined in the Unicode Standard 2.0, or the underscore (_).

  8. To save the updated package, on the File menu, click Save Selected Items.