Tuesday, 24 November 2015

Moving SUSDB.MDF to another drive

Stop the services locking the SUSDB open

net stop "update services"
net stop "w3svc"

Use SQLCMD to drop the database.

sqlcmd -E -S np:\\.\pipe\MSSQL$MICROSOFT##SSEE\sql\query -Q "sp_detach_db 'SUSDB'"

Use xcopy to move the SUSDB.mdf and SUSDB_LOG.ldf to the D:\

Reattach the database

sqlcmd -E -S np:\\.\pipe\MSSQL$MICROSOFT##SSEE\sql\query -Q "sp_attach_db @dbname=N'SUSDB',\
       @filename1=N'D:\WSUS\SUSDB\SUSDB.mdf',\
       @filename2=D'D:\WSUS\SUSDB\SUSDB_log.ldf'"

Start the services

net start "update services"
net start "w3svc"

No comments:

Post a Comment