Unanswered: Using a stored procedure parameter to access a column
I trying to create a general stored procedure which updates 1 out of 140 columns depending on the column name provided as a parameter.
I'm not having much luck, just wondering if anyone else had tried to do this and whether it is actually possible?
Any help would be much appreciated
Basically its a table of 'performances' for a small venue, and there are a number of columns representing the status of the seats for that date (available/booked).
The stored procedure is designed to 'book' a requested seat, the input parameter is the required seat eg. 'A1'. The easiest way I could see to do this was to then use this seat name to update the appropriate column.
A unique performanceID is also passed as a parameter so it would only ever access a single record....
SET (@RequiredSeat) = 1 --represents 'booked'
WHERE Performances.PerformanceID = @PerformancesID
I wanted to get the 'SET' statement to use the value of the @RequiredSeat parameter as the column name...
The reason I'm trying to do it like this, is I couldn't come up with a better way of identifying which column to update without having a seperate stored procedure for each one, which seemed inefficient...
Any suggestions would be much appreciated