I am trying to create a sql statement like
set @sql = 'select @stage1 = count(MY_ID)
where ' + @filter
and run it with
However this generates an error
Must declare the variable '@stage1'.
If I run statement
select @stage1 = count(MY_ID)
the var @stage 1 is set. Also @sql and @filter are all defind as varchars.