嗨选择,我有以下SQL存储过程查询如何下令列的#在SQL查询
@colindex int
SELECT
di.folio,
di.name,
di.region,
di.amount
FROM datainfo di
WHERE di.isactive = 1
ORDER BY [email protected] 'where colindex is the index of the column returned
例子:
如果@colindex = 1则列,我想顺序是“folio”列。
如果@colindex = 4,那么我想要排序的列是“amount”列。
关于如何在SQL中处理此问题的任何线索?
谢谢。
也可能有@ordertype(asc或desc)并将其添加到查询中? – VAAA 2013-02-19 17:42:49
@VAAA ....是的:-) – 2013-02-19 17:51:20
关于如何做到这一点的任何线索?非常感谢你的帮助! – VAAA 2013-02-19 17:53:24