問題描述
我在 SQL Server 2005 中有一個(gè)列,它將版本號存儲(chǔ)為我想要排序的字符串.我一直無法找到如何對此列進(jìn)行排序,盡管我猜它是某種自定義函數(shù)或比較算法.
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.
任何人都可以指出我從哪里開始的正確方向嗎?我可能在谷歌上搜索錯(cuò)誤的東西.
Can anyone point me in the right direction of where to start? I may be googling the wrong stuff.
干杯
崔斯
推薦答案
我會(huì)使用單獨(dú)的 int 列(例如,如果您正在跟蹤主要 + 次要版本,則使用 MajorCol + MinorCol)并運(yùn)行類似
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
在我的查詢中.
這篇關(guān)于SQL Server 的自定義排序函數(shù)的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網(wǎng)!