SQL Server installation history

Goal

To obtain sql server installation history like log file name, feature name, who install it and what was installed or updated

My way of achieving it

Again using xp_cmdshell, registry and sql server installation logs. The script is taking information from

HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Installer\UserData\S-1-5-18\Products

and from

C:\Program Files\Microsoft SQL Server\*.log

The result of these is joined based on the registry key name and after that some info is read from the log files. The script doesn’t show the products, sql server related that were uninstalled and sometime because sql server logs might have been deleted no info is returned when trying to join the results obtained by searching those 2 locations. Whatever will be the reason, the script has commented select from the various tables and we can find at least half of the information that we want. The script performance and time execution can be improved and I want to mention that since I am checking all those log files and since I am applying some string functions to raw data the execution might take minutes to complete. Maybe later I will try to improve it but for the time being I am ok with it.

The output looks similar to this

sqlsrvrinsthistory

The script can be downloaded from here

 

Leave a Reply

Your email address will not be published. Required fields are marked *