Share via


Discovering SQL Server 2005 Instances by Querying System Center Configuration Manager (SCCM)

SQL Server 2005 extended support will end on April 12, 2016. After this date, Microsoft will no longer be releasing security updates for this product. In the article, we will query the System Center Configuration Manager (SCCM) 2012 database to obtain the number and editions of SQL Server 2005 instances that are installed, along with those instances that are in use. This allows us to prioritize our upgrade efforts with these in-use instances first, while providing a different set of instructions to customers that have SQL Server 2005 installed, but no longer in use.

In terms of detection, the Microsoft Assessment and Planning (MAP) toolkit is a great option as highlighted here. However, by leveraging the data collected by SCCM, we can not only get the number of instances installed, but also determine if the instances are still in use.

The following queries should be executed against your SCCM database.

-- Get counts of INSTALLED software SELECT ProductName0, COUNT(ProductName0) AS Totals FROM [v_GS_INSTALLED_SOFTWARE_CATEGORIZED] WHERE ProductName0 like '%SQL SERVER%' AND ProductName0 like '%2005%' AND ProductVersion0 like '9.%' GROUP BY ProductName0 ORDER BY COUNT(ProductName0) DESC

Example results:

Results1

-- -- Get counts of RECENTLY USED software SELECT msiDisplayName0, COUNT(msiDisplayName0) AS Totals FROM v_GS_CCM_RECENTLY_USED_APPS WHERE ExplorerFileName0 = 'sqlservr.exe' AND ProductVersion0 like '9.%' GROUP BY msiDisplayName0 ORDER BY COUNT(msiDisplayName0) DESC

Example results:

Results2

If the queries above return existing SQL Server instance counts, you can execute the following queries to obtain additional information, including the machine name, top console user, and user associated with the machine. By leveraging Active Directory Users and Groups, you can then locate the associated email address of the users to contact regarding the instances discovered.

-- Get details of INSTALLED software SELECT CON.TopConsoleUser0, RSYS.User_Domain0, RSYS.User_Name0, RSYS.Netbios_Name0, INST.NormalizedName, INST.ProductVersion0, INST.ARPDisplayName0 FROM v_GS_INSTALLED_SOFTWARE_CATEGORIZED INST INNER JOIN v_r_system RSYS ON INST.resourceID = RSYS.resourceID LEFT JOIN v_GS_SYSTEM_CONSOLE_USAGE CON ON CON.resourceID = RSYS.resourceID WHERE INST.ProductName0 LIKE '%SQL SERVER%' AND INST.ProductName0 LIKE '%2005%' AND INST.ProductVersion0 LIKE '9.%' -- Get details of RECENTLY USED software SELECT CON.TopConsoleUser0, RSYS.User_Domain0, RSYS.User_Name0, RSYS.Netbios_Name0, APPS.LastUserName0, APPS.msiDisplayName0, APPS.ProductVersion0, APPS.* FROM v_GS_CCM_RECENTLY_USED_APPS APPS INNER JOIN v_r_system RSYS ON APPS.resourceID = RSYS.resourceID LEFT JOIN v_GS_SYSTEM_CONSOLE_USAGE CON ON CON.resourceID = RSYS.resourceID WHERE APPS.ExplorerFileName0 = 'sqlservr.exe' AND APPS.productversion0 LIKE '9.%'

Thanks,
Sam Lester (MSFT)