0

Based on few conditions I want to set a variable to true or false in Execute SQL Task. This is my query

If  ?  <> 0
    BEGIN
    If CAST( ?  as DATE) <> (select MAX(cast(Date as DATE)) from <Table>)
        begin 
        set ? OUTPUT = 'True'
        end
END

I have created 3 parameter mapping. Removing the condition set ? OUTPUT = 'True' is fine. But when I add this statement I am getting error.

I am sure this would be syntax error but I am unable to figure it out. I tried all these

set ? OUTPUT = 'True'
set ? = 'True'
    ? = 'True'

But nothing works and I end up with error. Please help.

Mahmoud Gamal
  • 78,257
  • 17
  • 139
  • 164
Harsha
  • 113
  • 9

1 Answers1

0

I think you should select it instead, but I wouldn't use output as the name.

If  ?  <> 0
    BEGIN
    If CAST( ?  as DATE) <> (select MAX(cast(Date as DATE)) from <Table>)
        begin 
        select 'True' as Result
        end
END

Map the result of the execute sql statement to the target variable.

Eric Hauenstein
  • 2,557
  • 6
  • 31
  • 41