Try our new Certificate Revocation List Check Tool
CRLcheck.exe is a tool developed to verify digital signatures of executable files. It collects files from known paths on your client, checks their signature, and checks Certificate Revocation Lists (CRL) and OCSP download. This helps avoid delays in launching files.
Category published:  SQL WSUS   Click on the Category button to get more articles regarding that product.

WSUS: Unable to Take WSUS SQL DB offline or Dettach (SQL Locks)

Posted by admin on 01.04.2015

We mainly have seen this on Small Business Servers SBS. We migrated WSUS to a standalone Server and wanted to remove the SBS integrated WSUS Server.

 

Problem 1:

WSUS Database lock prevents handling of SQL DB from Windows Update Server.

Error:

ALTER DATABASE failed because a lock could not be placed on database ‘SUSDB’. Try again later.

Unable to Uninstall WSUS Server Components after migrated to other server on old Server. (Sample SBS)

First task Stop Services:

Click Start, point to Programs, point to Administrative Tools, and then click Services.

Right-click IIS Admin Service, and then click Stop.

Right-click Update Services, and then click Stop.

Problem 2:

Still you are unable to take the DB offline. Mostly this was because the DB reaches some SQL Limit 2/20GB etc.

OR

There where locks on the SQL DB.

The lock means that the DB is unstable and should not be touched in this case. Because we don’t need it anymore (After WSUS was migrated to new Server) you can kill the process in SQL Management studio.

 

Here is how to connect to WSUS Database on Server 2003/2008R2 and 2012R2

Auf 2003:     \\.\pipe\MSSQL$MICROSOFT##SSEE\sql\query

Auf 2012R2:    \\.\pipe\microsoft##WID\tsql\query

 

 

Or with SQLCMD:

 

sqlcmd -S np:\\.\pipe\MSSQL$MICROSOFT##SSEE\sql\query

use master

alter database SUSDB set single_user with rollback immediate

go

sp_detach_db SUSDB

go

 

ERROR: ALTER DATABASE failed because a lock could not be placed on database ‘SUSDB’. Try again later.

 

Here is how to solve this:

 

Shows current locks

exec sp_who2


Shows the sessions locks that are on the SQL-Express DB.

Then kill all locks which are stuck.

Example Kills Lock with SPID 57:

kill 57

kill 56

You should be able to Dettach the Database now and clean up the WSUS.

 

Some external Links:

https://technet.microsoft.com/de-de/library/dd939918(v=ws.10).aspx


 Category published:  SQL WSUS   Click on the Category button to get more articles regarding that product.