Thursday, March 28, 2013

SQL Server Update Woes

There are various issues that can happen when trying to update SQL Server. For almost all there are workarounds, and they usually work well.

Today I had a trickier experience, and thought I'd share my findings. I wanted to install KB2494113 - "Security Update for SQL Server 2005 Service Pack 3". I got error 57A through Windows Updates. So I had to resort to downloading and installing the update manually.



The installation failed, but at least the summary had the real error message:
**********************************************************************************
Product Installation Status
Product                   : SQL Server Database Services 2005 (SQLEXPRESS)
Product Version (Previous): 4053
Product Version (Final)   :
Status                    : Failure
Log File                  : C:\Program Files (x86)\Microsoft SQL Server\90\Setup Bootstrap\LOG\Hotfix\SQL9_Hotfix_KB2494113_sqlrun_sql.msp.log
SQL Express Features      :
Error Number              : 1402
Error Description         : MSP Error: 1402  Could not open key: UNKNOWN\Components\GUID1\GUID2.   Verify that you have sufficient access to that key, or contact your support personnel.
----------------------------------------------------------------------------------

The relevant registry path can be found in 
HKLM\Software\Microsoft\Windows\CurrentVersion\Installer\UserData\S-1-5-18\Components\GUID1\GUID2
Where Guid1 and Guid2 are the specific paths from the error log above. Sure enough, I was not able to even access these keys as Administrator.


This blog post had the solution, although one important step was left out in workaround 1. In order to change the permissions of those folders, you first have to claim ownership.
I didn't feel comfortable changing ownership of the whole Components key, so I just changed the keys that were referenced in the error log above, namely GUID1\GUID2.

It's bad enough having to change the registry as local system, I didn't want to further endanger the stability of the system.

That means going through the following process:
  1. Attempt to install KB2494113
  2. On failure, get the registry key from the error from "View Summary"
  3. Run "psexec -i -s cmd.exe", then invoke "regedit"
  4. Navigate to HKLM\Software\Microsoft\Windows\CurrentVersion\Installer\UserData\S-1-5-18\Components\GUID1
  5. Right click the key GUID1 and select "Permissions". Click "Advanced".
  6. In the Permissions, Owner tab: Check "Replace owner on subcontainers and objects" then chose a valid user or group. Click "Apply". You'll get a message that tells you that it couldn't set the owner on some of the subkeys. That's alright in this case.
  7. In the Permissions, Permissions tab check "Replace all child object permissions with inheritable permissions frmo this object" and click "OK". Answer "Yes" when prompted.
  8. Goto 1 until the installation doesn't fail

In my case I had to tweak two dozen or so reg keys, but then it worked.

No comments: