Hi.I have table like this:CREATE TABLE dbo.#MyTable ( Column1 decimal(15,2), -- Column2 decimal(15,2), Column3 decimal(15,2), Column4 decimal(15,2), Column5 decimal(15,2), ... ColumnN decimal(15,2))
How to insert data to a given column but I do not know which column it will be during query execution. For example, firstly I calculate two values, @ColumnNumber, @Priceand now I would like to insert @Price into dbo.#MyTable into column which order number (in table) is equal to a @ColumnNumber.I don't want to do it like this:CASE @ColumnNumber WHEN 1 THEN BEGIN INSERT INTO dbo.#MyTable Column1 VALUES(@Price) END WHEN 2 THEN BEGIN INSERT INTO dbo.#MyTable Column2 VALUES(@Price) END WHEN N THEN BEGIN INSERT INTO dbo.#MyTable ColumnN VALUES(@Price) ENDENDIs there other solution?Thanks for your time.