How to parse a version number
Posted: Mon Jan 11, 2016 6:06 am
Hi Guys,
I'm currently working on a script that will enumerate SQL versions installed onm a machine to see if the version is the same or greater than the minimum version required to run our product. To achieve this, i have been mopdifying the Enumerate SQL Instances script.
I want to parse a variable I have created, MS_SQL_VERSION which retrieves the value of an installed SQL instance. The value might be for example 12.1.4213.0. I want to use parse string to grab the major version number which would be 12 in this case. I've been trying to find some information on how I would do this by specifying a pattern. I can't do this by trimming the string at a particular position since the major version number might be shorter than a two digit number for example 8.
If I was doing this in C#, I'd do something like take all the characters up to the first full stop. Can someone provide me with either some documentation on how to set up a parse string pattern, or show me how to spcify a pattern to grab the major version from a retrieved version string.
Many thanks,
Damien
I'm currently working on a script that will enumerate SQL versions installed onm a machine to see if the version is the same or greater than the minimum version required to run our product. To achieve this, i have been mopdifying the Enumerate SQL Instances script.
I want to parse a variable I have created, MS_SQL_VERSION which retrieves the value of an installed SQL instance. The value might be for example 12.1.4213.0. I want to use parse string to grab the major version number which would be 12 in this case. I've been trying to find some information on how I would do this by specifying a pattern. I can't do this by trimming the string at a particular position since the major version number might be shorter than a two digit number for example 8.
If I was doing this in C#, I'd do something like take all the characters up to the first full stop. Can someone provide me with either some documentation on how to set up a parse string pattern, or show me how to spcify a pattern to grab the major version from a retrieved version string.
Many thanks,
Damien