2

I can't quite find the answer to this. How can I evaluate an expression that contains arithmetic in SSIS. Specifically within a variable's expression field or in the Execute SQL task -> SQL statement as expression.

I have a user defined variable 'Width' that is assigned to a variable as type decimal. 388.00

and I have another variable Range as type decimal. I need to create a dynamic sql statement but I need these values to evaluate using the following:

@[User::Width] - @[User::Range]

This doesn't work.

Cœur
  • 37,241
  • 25
  • 195
  • 267
Cjust689
  • 75
  • 10
  • In execute sql task you use a question mark for parameters. The ? is replaced based on the parameter order. So it might look like ? - ? – Joe C Jul 07 '17 at 16:09
  • Possible duplicate of [How to pass variable as a parameter in Execute SQL Task SSIS?](https://stackoverflow.com/questions/7610491/how-to-pass-variable-as-a-parameter-in-execute-sql-task-ssis) – Tab Alleman Jul 07 '17 at 19:09

1 Answers1

0

You can use Expressions to achieve this.

  1. Double click on the Execute SQL Task
  2. GoTo Expression Tab
  3. Select the SqlStatmentSource Property
  4. Write the expression you want, example:

    "SELECT * FROM dbo.MyTable
    WHERE [quantity] = " + (DT_WSTR,50)(@[User::Width] - @[User::Range])
    

You can check my asnwer at Parameter Mapping using an Execute SQL Task (similar case)

Hadi
  • 36,233
  • 13
  • 65
  • 124