Move SharePoint Content Database From One Drive To Another Drive On Same Server

Hi readers, this blog may help you to understand how we can move a SharePoint content database from one drive to another drive at the same SQL Server.

As we know when we create a content database from SharePoint Central Administration console it will create a database at SQL server, by default if any database created at SQL server at backend then two files get created automatically 1) MDF file 2) LDF file at C:\Program files\MSSQL.1\MSSQL\Data.
 
So, here MDF file is the main database file and each MDF file will be associated with an LDF File to generate the transaction logs, so we should move MDF file along with LDF file so that to recover the data easily.
 
In my scenario, I have one web application with two content database, which was stored on C Drive. So, I want to move one content database from C Drive to E Drive.
 
So before performing any action in SQL server, first we need to stop the connection in that particular content database, so my first step will be to remove the content database from my web application.
  • Login to Central Administration and click Application management
  • Click on the content database and select your web application
  • Then select the content database which you are going to remove
  • Check the remove content database and click ok
Move SharePoint Content Database From One Drive To Another Drive On Same Server
  • Then Login to SQL Server with farm admin account
  • Then right-click the database and select Task to take a backup first
Move SharePoint Content Database From One Drive To Another Drive On Same Server

Once the backup is completed successfully, again right-click the database and select task and choose Detach.

Move SharePoint Content Database From One Drive To Another Drive On Same Server

On the screen is Detached, you can see how many connections as there for that particular content database. Just unselect the connection list and click Detach.

Once Detach is completed successfully, that particular database will not be visible under database folder then copy the MDF along with LDF file from source to a destination drive.
 
After copying the file, again open the SQL Server Management Server and right click the database folder and select “Attach”
 
Move SharePoint Content Database From One Drive To Another Drive On Same Server

Then browse for the moved MDF file and click Add. It will add the MDF file with LDF file to the SQL server then attached Database will be visible under the Database folder.

Now, SQL part got completed, now open SharePoint Management shell to associate back to the web application using the following Command.

  1. Mount-SPContentDatabase “Databasename” –DatabaseServer “ServerName” –WebApplication https://sharepointserver:portnumber  
Move SharePoint Content Database From One Drive To Another Drive On Same Server
 
And finally perform the IISRESET, then you can use the content database as usual.