How to compare software versions using SQL Server?

后端 未结 16 2186
清酒与你
清酒与你 2020-12-03 07:30

When trying to compare software versions 5.12 to 5.8, version 5.12 is newer, however mathematically 5.12 is less than 5.8. How would I compare the two versions so that a new

16条回答
  •  伪装坚强ぢ
    2020-12-03 08:09

    I'll give you the most shortest answer of this.

    with cte as (
        select  7.11 as ver
        union all
        select 7.6
    )
    
    select top 1 ver from cte
          order by parsename(ver, 2), parsename(cast(ver as float), 1)
    

提交回复
热议问题