Matt writes "Hi there,In a sql script I have declared 52 variables - one for each week of the year.I have a while.. loop which gets the data for each week of the year. What I want to be able to do is concatenate the @counter variable with 'week' as a variable name so I get week1 on the first loop, week2 on the second etc.so.. declare @week1 intdeclare @week2 int etc.while loop..select t.minprice, 'week'+ (convert(varchar(2), @counter)) as availabilityIndicator from testVillasMatrix twhere t.weekNum=@counterand t.propertyid=@pid
now.. select @'week' + convert(varchar(2), @counter)) = minprice
but this fails.. am I trying to do something that is impossible? I was hoping to find a function called evaluate() that I could use to set the variable.Any help would be gratefully received..thanks in advance..Matt"