Unanswered: getting value of the variable with its name assigned to a string
I am using Sybase ASE 15.x version. I have some variable @var1, @var2, @var3,...,@var40 in my stored procedure. i need to get a string to be executed with these 40 variables. How can i put this in a loop?
select @sql = @sql + 'AND table.value1 = @var1'
where @var1 is not null
select @sql = @sql + 'AND table.value2 = @var2'
where @var2 is not null
select @sql = @sql + 'AND table.value40 = @var40'
where @var40 is not null
i can do like this
while @i <= 40
select @sql = @sql + 'AND table.value'+covert(varchar(10),@i) || ' = @var'+convert(varchar(10),@i) where --- is not null
---> here is what i am facing the issue.
How will i get the value of the variables in a loop?