且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何使用 SQL Server 查询对“版本号"列进行一般排序

更新时间:2023-01-20 20:03:34

如果您使用的是 SQL Server 2008

If You are using SQL Server 2008

select VersionNo from Versions order by cast('/' + replace(VersionNo , '.', '/') + '/' as hierarchyid);

什么是hierarchyid

2000、2005、2008 年的解决方案:此处为 T-SQL 排序挑战的解决方案.

Solutions for 2000, 2005, 2008: Solutions to T-SQL Sorting Challenge here.

挑战