Relocate Sharepoint Database

These instructions to relocate your Companyweb / Sharepoint database comes from David Copeland at Microsoft.

Stop the Companyweb site as well as any other web sites that have been extended with Windows SharePoint Services (WSS).

Create the new directory/drive where the databases will be moved to (in the example below is e:\newlocation)

I would suggest that the directory have the same permissions as the
\program files\microsoft sql server\mssql$sharepoint\data directory has

Replace “servername” with the name of your server.

The following section will detatch (the WSS config and content databases)
c:> OSQL -E -S servername\sharepoint <Enter>
sp_detach_db ‘STS_Config’ <Enter>
go <Enter>
sp_detach_db ‘STS_servername_1’ <Enter>
go <Enter>
Once the databases are detached, then using Explorer or another command prompt you should be able to copy the databases to their new location. (would suggest copying instead of moving just in case there is any kind of problem)
sp_attach_db @dbname = ‘STS_Config’, @filename1= ‘E:\new location\STS_config.mdf’, @filename2 = ‘E:\new
 location\STS_Config_log.ldf’ <Enter>
go <Enter>
sp_attach_db @dbname = ‘STS_servername_1’, @filename1= ‘E:\new location\STS_servername_1.mdf’, @filename2 = ‘E:\new location\STS_servername_1_log.ldf’ <Enter>
go <Enter>
Restart any of the web sites that had been stopped previously

Hope that helps,
David Copeland
Microsoft Small Business Server Support

2 thoughts on “Relocate Sharepoint Database


Leave a Reply

Your email address will not be published. Required fields are marked *