SQL Server 的自定义排序函数
我在 SQL Server 2005 中有一个列,它将版本号存储为我想要排序的字符串.我一直无法找到如何对此列进行排序,尽管我猜它是某种自定义函数或比较算法.
I have a column in SQL Server 2005 that stores a version number as a string that i would like to sort by. I have been unable to find out how to sort this column, although i am guessing it would be some kind of custom function or compare algorithm.
任何人都可以指出我从哪里开始的正确方向吗?我可能在谷歌上搜索错误的东西.
Can anyone point me in the right direction of where to start? I may be googling the wrong stuff.
干杯
崔斯
推荐答案
我会使用单独的 int 列(例如,如果您正在跟踪主要 + 次要版本,则使用 MajorCol + MinorCol)并运行类似
I'd use separate int columns (e.g. MajorCol + MinorCol if you are tracking major + minor versions) and run something like
order by MajorCol, MinorCol
在我的查询中.
相关文章