1
BEGIN
2
DECLARE originalOSName VARCHAR(255) DEFAULT '';
3
DECLARE hyperV VARCHAR(10) DEFAULT '';
4
DECLARE R2 VARCHAR(5) DEFAULT '';
5
DECLARE x64 VARCHAR(5) DEFAULT '';
6
#Add a space to the end of the OS name to help with the matching
7
set originalOSName = concat(osName, ' ');
8
#####Check Hyper-V
9
IF originalOSName LIKE '%Hyper-V%' THEN SET hyperV = ' Hyper-V';
10
END IF;
11
#####Check R2
12
IF originalOSName LIKE '% R2 %' THEN SET R2 = ' R2';
13
END IF;
14
#####Check x64
15
IF originalOSName LIKE '% x64 %' THEN SET x64 = ' x64';
16
END IF;
17
CASE
18
#Server OSs
19
WHEN originalOSName LIKE '% 2012 %' THEN SET formattedOSName = CONCAT('Windows', hyperV, ' Server 2012', R2, x64);
20
WHEN originalOSName LIKE '% 2011 %' THEN SET formattedOSName = CONCAT('Windows 2011', x64);
21
WHEN originalOSName LIKE '% 2008 %' THEN SET formattedOSName = CONCAT('Windows', hyperV, ' Server 2008', R2, x64);
22
#The next case will cover 'Server 2008 Hyper-V', as the OS returns the value without the '2008'
23
WHEN originalOSName LIKE '%Hyper-V%' THEN SET formattedOSName = CONCAT('Windows Hyper-V Server', x64);
24
WHEN originalOSName LIKE '% 2003 %' THEN SET formattedOSName = CONCAT('Windows 2003', x64);
25
#Workstation OSs
26
WHEN originalOSName LIKE '% 10 %' THEN SET formattedOSName = CONCAT('Windows 10', x64);
27
WHEN originalOSName LIKE '%Microsoft Windows Technical Preview%' THEN SET formattedOSName = CONCAT('Windows 10', x64);
28
WHEN originalOSName LIKE '% 8.1 %' THEN SET formattedOSName = CONCAT('Windows 8.1', x64);
29
WHEN originalOSName LIKE '% 8 %' THEN SET formattedOSName = CONCAT('Windows 8', x64);
30
WHEN originalOSName LIKE '%Windows Developer Preview%' THEN SET formattedOSName = CONCAT('Windows 8', x64);
31
WHEN originalOSName LIKE '% 7 %' THEN SET formattedOSName = CONCAT('Windows 7', x64);
32
WHEN originalOSName LIKE '%Vista%' THEN SET formattedOSName = CONCAT('Windows Vista', x64);
33
WHEN originalOSName LIKE '% XP %' THEN SET formattedOSName = CONCAT('Windows XP', x64);
34
WHEN originalOSName LIKE '% 2000 %' THEN SET formattedOSName = 'Windows 2000';
35
WHEN originalOSName LIKE '% NT %' THEN SET formattedOSName = 'Windows NT';
36
#New Computer
37
WHEN originalOSName LIKE '%NewComputer%' THEN SET formattedOSName = '';
38
#If any string does not match these cases, just return the string
39
ELSE SET formattedOSName = originalOSName;
40
END CASE;
41
END