How to move WSUS MSDE database files to another drive using OSQL

This will work for any MSDE database, you just need to know the name of the DB, and stop the relevant services tied to it (not SQL, of course!)

Copy this to a batch file or to a command line.  This makes the assumptions:

  • MSDE install is in default location, and instance was named WSUS
  • You want to move the DB to directory d:\wsusdb

If these are not true you need only tweak the commands below to match your end goal.


net stop "update services"
net stop w3svc
cd "C:\Program Files\Microsoft SQL Server\MSSQL$WSUS\Binn"
osql -E -S %computername%\wsus -Q "exec sp_detach_db 'SUSDB'"
md d:\WSUSDB
move "C:\Program Files\Microsoft SQL Server\MSSQL$WSUS\Data\SUS*.*" d:\wsusdb
osql -E -S %computername%\wsus -Q "exec sp_attach_db @dbname=N'SUSDB', @filename1=N'D:\WSUSDB\SUSDB.mdf', @filename2=N'D:\WSUSDB\SUSDB_log.ldf'"
net start "update services"
net start w3svc


* Note - If you're trying to move any other MSDE database, you need to know the name. 

    osql -E -S %computername%\wsus -Q "sp_databases"

Will output this information for you.

 

If you found this document useful, please let me know - drop me a quick email.

Last updated 08/03/2005