To fix something, it should be broken first. I keep playing with my lab and eventually end up breaking stuff. This time, while patching my own lab environment with latest service pack, I ran into below error about MissingRegistryKeyException.
The registry key System\CurrentControlSet\Services\MSSQLSERVER\Performance is missing.
I opened the error stack from detail.txt. It goes from bottom to top. If I arrange them in the right order, it looks like below.
Here is the exception:
Microsoft.SqlServer.Configuration.SqlEngine.MissingRegistryKeyException: The registry key System\CurrentControlSet\Services\MSSQLSERVER\Performance is missing.
If we read the function names, it’s clear that the setup is trying to patch performance counters and error message also makes sense.
- User regedit.exe (Start > Run > RegEdit) and go to System\CurrentControlSet\Services\MSSQLSERVER\Performance to verify if this registry key is missing. If it is missing, take a backup of the whole registry (just to be on the safer side) and manually create the registry key as shown below:
- Follow below blog to recreate the performance counters. SQL SERVER – Performance Counter Missing: How to Get Them Back?
After that I installed patch again and it worked like a charm.
Let me know if you have faced any such issues in the future.
Reference: Pinal Dave (https://blog.sqlauthority.com)
Thanks for sharing this. Simply adding the registry key worked like a charm for the March 2020 SQL 2012 SP4 Cumulative Update.