Tuesday, 29 November 2016

Moving the WSUS Windows Internal Database

You can move WSUS content using the wsusutil.exe utility as per:

However, this doesn't move the SQL database.

Here's a quick guide to move the SQL database to another volume (from the default location in C drive to the same relative path on E drive).

First, stop the web server and WSUS services:

E:\>net stop W3SVC
E:\>net stop WsusService

Next, detach the database using sqlcmd.exe (path may be different, dependent on version of SQL):

E:\>cd /d "%ProgramFiles%\Microsoft SQL Server\100\Tools\Binn"

C:\Program Files\Microsoft SQL Server\100\Tools\Binn>sqlcmd -S \\.\pipe\mssql$microsoft##ssee\sql\query -E
1> EXEC sp_detach_db @dbname = 'SUSDB'
2> GO

Leave the sqlcmd session open and move the database files to your desired destination. Once the move is complete, attach the database again:

1> EXEC sp_attach_db @dbname = 'SUSDB', @filename1 = 'e:\WSUS\UpdateServicesDbFiles\SUSDB.mdf', @filename2 = 'e:\WSUS\UpdateServicesDbFiles\SUSDB_log.ldf'
2> GO

All done!