Declare @col varchar(30)
SET @col = '[' + cast(@Year as varchar(20)) + '_Growth' + ']';
SET @col = cast (cast(@Number as money)*100 as varchar(50) ) + '%'
WHERE X3_Desc = @X3_Desc AND X4_Desc = @X4_Desc
i have a colum with name [2011_Growth] and i have this 2011 in @Year variable.
so i create @col which has [2011_Growth] value in it, but its not updating the value
but if i place
SET [2011_Growth] = cast (cast(@Number as money)*100 as varchar(50) ) + '%'
directly into the query its working fine, but not with using of @col variable,
I cant avoid @col variable as i have @Year coming as parameter and based on it i decide the colum which needs to be update, how can i do that with my @col variable or some other way.