Pass variable as column name in stored procedure
Posted on 2005-04-19
I have the following stored procedure:
CREATE procedure procGetAssignedUserApplications_revised
ORDER BY @column + '''' + @sort + ''''
I keep getting an error saying:
The SELECT item identified by the ORDER BY number 1 contains a variable as part of the expression identifying a column position. Variables are only allowed when ordering by an expression referencing a column name.
Even though I am trying to sort by a column name...how can I resolve this?