Hi All,
I need to strip out a version number from a string. The version number will always be a lower case "v" with a leading space. Appears that my SQL Server environment is ignoring lower case. I am searching for a setting, bout can't find it. I hope that is the issue; or I will need to have a case with lower case v with 0 to 9 (10 possibilities).
Raw Data
Test Notary v1.1 to Test Notary
Test Sale Valuation to Test Sale Valuation (No Changes)
Test Referral v.1.2 to Test Referral
Test VM to Test VM (No Changes)
Code above works great, except entries like Test VM will return just Test. Basically ignoring the case of the letter "v".
Any thoughts are greatly appreciated. Scratching my head on this one for show.
Thanks in Advance
Steve Medvid
IT Consultant & Web Master
I need to strip out a version number from a string. The version number will always be a lower case "v" with a leading space. Appears that my SQL Server environment is ignoring lower case. I am searching for a setting, bout can't find it. I hope that is the issue; or I will need to have a case with lower case v with 0 to 9 (10 possibilities).
Code:
SELECT
a.TemplateName,
CASE CHARINDEX(' v',a.TemplateName)
WHEN 0 THEN a.TemplateName
ELSE SUBSTRING(a.TemplateName,1,CHARINDEX(' v',a.TemplateName)-1)
END as TemplateNameNoVersion
FROM dbo.tbl_Data a
WHERE a.TemplateName Like '% v%' OR a.TemplateName Like '% V%'
GROUP BY a.TemplateName
ORDER BY 1
Raw Data
Test Notary v1.1 to Test Notary
Test Sale Valuation to Test Sale Valuation (No Changes)
Test Referral v.1.2 to Test Referral
Test VM to Test VM (No Changes)
Code above works great, except entries like Test VM will return just Test. Basically ignoring the case of the letter "v".
Any thoughts are greatly appreciated. Scratching my head on this one for show.
Thanks in Advance
Steve Medvid
IT Consultant & Web Master