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
How to parse a version number
Re: How to parse a version number
Damien,
I used the parse string statement and it worked okay. I've attached a project (based on the blank template) containing an example. Open it and inspect the parse string statement to see what I used. It works on any number of characters before the first "." token.
Does it do what you want to do?
I used the parse string statement and it worked okay. I've attached a project (based on the blank template) containing an example. Open it and inspect the parse string statement to see what I used. It works on any number of characters before the first "." token.
Does it do what you want to do?
- Attachments
-
- TestParse.7z
- (978 Bytes) Downloaded 323 times
Peter. Smartly dressed, he still resembles an unmade bed.
InstallAware MVP
InstallAware MVP
Re: How to parse a version number
That's fantastic bokkie, that you so much for the example it is incredibly simple. For anyone just reading this post, the pattern simply needs to be set to a full stop e.g. "." (don't add the quotes) then you can just tell it to match up until that point.
Re: How to parse a version number
Glad to have helped. I sometimes come up with over-the-top answers but this was one of those slap-my-own-face problems because it seemed just "too simple". 
What was a little confusing is the the MSIcode statement doesn't tell you what delimiter is used. You only see it when you select the statement and press [RETURN] to open its dialog. Maybe the dev team might consider adding it to the visible MSIcode statement?

What was a little confusing is the the MSIcode statement doesn't tell you what delimiter is used. You only see it when you select the statement and press [RETURN] to open its dialog. Maybe the dev team might consider adding it to the visible MSIcode statement?
Peter. Smartly dressed, he still resembles an unmade bed.
InstallAware MVP
InstallAware MVP
Who is online
Users browsing this forum: No registered users and 173 guests