Compare software version numbers - which is higher?

Rob M 61 Reputation points
2022-08-24T18:39:23.93+00:00

Hi,

I need a query that is able to properly test if one version number is higher than another. When I use the where condition:

Version > "8.0.2020.8"

The result is returning versions that are lower than this version. Is it possible to inspect the 3rd section, in this example 2020, and compare that part against another version number?

value1 = 8.0.2020.8
value2 = 8.0.730.0

When these are compared as strings, 8.0.730.0 is appearing in my result.

Thank you!
Rob

Transact-SQL
Transact-SQL
A Microsoft extension to the ANSI SQL language that includes procedural programming, local variables, and various support functions.
4,551 questions
{count} votes

6 answers

Sort by: Most helpful
  1. Rob M 61 Reputation points
    2022-08-24T21:27:08.85+00:00

    Using "not like" doesn't filter out the lower versions this way. I was hoping it would work.