1
BEGIN
2
DECLARE originalOSName VARCHAR(255) DEFAULT '';
3
DECLARE formattedOSName VARCHAR(255) DEFAULT '';
4
DECLARE hyperV VARCHAR(10) DEFAULT '';
5
DECLARE R2 VARCHAR(5) DEFAULT '';
6
DECLARE x64 VARCHAR(5) DEFAULT '';
7
#Add a space to the end of the OS name to help with the matching
8
SET originalOSName = CONCAT(osName, ' ');
9
#####Check Hyper-V
10
IF originalOSName LIKE '%Hyper-V%' THEN SET hyperV = ' Hyper-V';
11
END IF;
12
#####Check R2SER
13
IF originalOSName LIKE '% R2 %' THEN SET R2 = ' R2';
14
END IF;
15
#####Check x64
16
IF originalOSName LIKE '% x64 %' THEN SET x64 = ' x64';
17
END IF;
18
############################## ATTENTION #####################################
19
##### IF YOU MODIFY THIS PROCEDURE FOR THE LOVE OF GOD, PLEASE UPDATE #####
20
##### NormalizeOperatingSystemForPatching() METHOD IN StringUtilities #####
21
##############################################################################
22
CASE
23
#Exception Case for Windows 10 Enterprise 2016
24
WHEN (originalOSName LIKE '% 2016 %' AND originalOSName LIKE '% 10 %') THEN SET formattedOSName = CONCAT('Windows 10', x64);
25
#Server OSs
26
WHEN originalOSName LIKE '% 2019 %' THEN SET formattedOSName = CONCAT('Windows', hyperV, ' Server 2019', R2, x64);
27
WHEN originalOSName LIKE '% 2016 %' THEN SET formattedOSName = CONCAT('Windows', hyperV, ' Server 2016', R2, x64);
28
WHEN originalOSName LIKE '% 2012 %' THEN SET formattedOSName = CONCAT('Windows', hyperV, ' Server 2012', R2, x64);
29
WHEN originalOSName LIKE '% 2011 %' THEN SET formattedOSName = CONCAT('Windows 2011', x64);
30
WHEN originalOSName LIKE '% 2008 %' THEN SET formattedOSName = CONCAT('Windows', hyperV, ' Server 2008', R2, x64);
31
#The next case will cover 'Server 2008 Hyper-V', as the OS returns the value without the '2008'
32
WHEN originalOSName LIKE '%Hyper-V%' THEN SET formattedOSName = CONCAT('Windows Hyper-V Server', x64);
33
WHEN originalOSName LIKE '% 2003 %' THEN SET formattedOSName = CONCAT('Windows Server 2003', x64);
34
WHEN originalOSName LIKE '% Server %' THEN SET formattedOSName = CONCAT('Windows Server', x64);
35
#Workstation OSs
36
WHEN originalOSName LIKE '% 10 %' THEN SET formattedOSName = CONCAT('Windows 10', x64);
37
WHEN originalOSName LIKE '%Microsoft Windows Technical Preview%' THEN SET formattedOSName = CONCAT('Windows 10', x64);
38
WHEN originalOSName LIKE '% 8.1 %' THEN SET formattedOSName = CONCAT('Windows 8.1', x64);
39
WHEN originalOSName LIKE '% 8 %' THEN SET formattedOSName = CONCAT('Windows 8', x64);
40
WHEN originalOSName LIKE '%Windows Developer Preview%' THEN SET formattedOSName = CONCAT('Windows 8', x64);
41
WHEN originalOSName LIKE '% 7 %' THEN SET formattedOSName = CONCAT('Windows 7', x64);
42
WHEN originalOSName LIKE '%Vista%' THEN SET formattedOSName = CONCAT('Windows Vista', x64);
43
WHEN originalOSName LIKE '% XP %' THEN SET formattedOSName = CONCAT('Windows XP', x64);
44
WHEN originalOSName LIKE '% 2000 %' THEN SET formattedOSName = 'Windows 2000';
45
WHEN originalOSName LIKE '% NT %' THEN SET formattedOSName = 'Windows NT';
46
#New Computer
47
WHEN originalOSName LIKE '%NewComputer%' THEN SET formattedOSName = '';
48
#If any string does not match these cases, just return the string
49
ELSE SET formattedOSName = originalOSName;
50
END CASE;
51
RETURN formattedOSName;
52
END