Version number sorting in Sql Server

前端 未结 7 1119
说谎
说谎 2021-01-13 05:35

I have a table that stores the versions as under

Declare @tblVersion table(VersionNumber varchar(100))
 Insert into @tblVersion Values(\'1.3.1\')
 Insert int         


        
相关标签:
7条回答
  • 2021-01-13 06:37

    If you are using SQL Server 2008 or later, you can leverage the hierarchyID data type:

    select * from @tblVersion
    order by CAST('/'+REPLACE(VersionNumber,'.','/')+'/' as hierarchyID)
    
    0 讨论(0)
提交回复
热议问题