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 newer version returns 'Y'?
SELECT CASE WHEN 5.12 > 5.8 THEN 'Y' ELSE 'N' END
Possible Solutions
SQL Compare allows you to work with live SQL Server databases, snapshots, script folders, and native backups. You can compare your SQL Server databases, analyze differences, and perform error-free schema synchronization using generated SQL scripts.
You can also compare the schema of two databases or of two versions of the same database. For more information, see How to: Use Schema Compare to Compare Different Database Definitions.
You could use hierarchyid
Which you can use by putting a /
at the end and start of the string and casting it
e.g.
SELECT CASE WHEN cast('/5.12/' as hierarchyid) > cast('/5.8/' as hierarchyid) THEN 'Y' ELSE 'N' END
That returns a Y
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With