SQL Server 的自定义排序函数 [英] Custom Sorting Function - of SQL Server

查看:61
本文介绍了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

在我的查询中.

这篇关于SQL Server 的自定义排序函数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆