Quick-n-Dirty: Here's what I WISH would work...
-------------------------------
Alter Procedure usp_getStuff
(
@sName varchar(50),
@iSortCol int = 1
)
As
SELECT sName, sStuff, iOtherStuff FROM tTable
WHERE (@sName IS NULL) OR (sName = @sName)
ORDER BY @iSortCol
-------------------------------
...but it DOESN'T work. I'm not allowed to "variably" define the ORDER BY column.
I get the following ADO error when trying to save:
[ol]
The SELECT item identified by the ORDER BY number 1 contains a variable as part of the expression identifying column positions. Variables are only allowed when ordering by an expression referencing a column name.
[/ol]
So far, I've not been able to identify a way to SORT by a Variable Column Reference...
-------------------------------
Alter Procedure usp_getStuff
(
@sName varchar(50),
@iSortCol int = 1
)
As
SELECT sName, sStuff, iOtherStuff FROM tTable
WHERE (@sName IS NULL) OR (sName = @sName)
ORDER BY @iSortCol
-------------------------------
...but it DOESN'T work. I'm not allowed to "variably" define the ORDER BY column.
I get the following ADO error when trying to save:
[ol]
The SELECT item identified by the ORDER BY number 1 contains a variable as part of the expression identifying column positions. Variables are only allowed when ordering by an expression referencing a column name.
[/ol]
So far, I've not been able to identify a way to SORT by a Variable Column Reference...