开发者

Dynamic ORDER BY in SQL Server

I saw some topics about this, but the problem is that the solutions required a "switch case"... Like this

I have a table with a lot of columns, is there a way to do a dyna开发者_如何学运维mic sort without the switch?


No.

Unless you use dynamic SQL.

Or you can use ROW_NUMBER() to generate some arbitrary sequences to sort on... but this is no different to CASE just moves the complexity around.

To be honest, if I had one of 10 columns to sort on, I'd make it happen on the client in a sortable grid...

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜