Move Content Databases in SharePoint Server
Move Content Databases in SharePoint Server
IMPORTANT
This article only describes how to move content databases. For information about how to move other kinds of databases
that are associated with SharePoint Server, see Move or rename service application databases in SharePoint Server and Move
all databases in SharePoint Server.
You can move content databases by using the SharePoint Central Administration website or Microsoft PowerShell,
and SQL Server tools. Which tool that you use depends on what kind of environment you have deployed, what
your schedule requires, and what service level agreements that you have made with your organization.
IMPORTANT
To move the content database file within the same instance SQL Server we recommend that you use the FILENAME
clause of the ALTER DATABASE statement. For more information, see Move User Databases.
IMPORTANT
To move a content database to another instance of SQL Server or to another server, we recommend that you use
procedures found in Database Detach and Attach (SQL Server) or Back Up and Restore of SQL Server Databases.
5. Copy or move the content database .mdf, .ndf, and .ldf files from the source location to the destination
location using File Explorer.
6. Attach the content database to the new SQL Server instance.
7. Add the content database to the destination web application in SharePoint Server.
IMPORTANT
Use the identical name when you add the content database or SharePoint Server creates a new content database.
8. Restart all service applications and services that you paused in step 2.
NOTE
The procedures in this section use Central Administration to move content databases. However, the first procedure, must be
performed by using PowerShell.
NOTE
If you are moving a content database to a different farm, you must make the server farm account a member of the
Administrators group on the database server during the restore process. This enables the account to replicate the security
setting for the databases. This access level can be removed after the content database is moved. For more information, see
Account permissions and security settings in SharePoint Server 2016.
The destination farm must be running the same version or a later version of SharePoint Server than the source
farm is running.
1. To record which content databases are associated with each web application
1. Verify that you have the following memberships:
securityadmin fixed server role on the SQL Server instance.
db_owner fixed database role on all databases that are to be updated.
Administrators group on the server on which you are running the PowerShell cmdlets.
The dbcreator and securityadmin fixed server roles on the destination server, in order to attach the
database and configure SQL Server logins.
An administrator can use the Add-SPShellAdmin cmdlet to grant permissions to use SharePoint Server
cmdlets.
NOTE
If you do not have permissions, contact your Setup administrator or SQL Server administrator to request
permissions. For additional information about PowerShell permissions, see Add-SPShellAdmin.
> [!NOTE]
> We recommend that you use Microsoft PowerShell when performing command-line administrative tasks. The Stsadm
command-line tool has been deprecated, but is included to support compatibility with previous product
versions.
NOTE
If the content database does not appear in the list, it might be associated with another web application. To select
another web application, on the Web Application menu, click Change Web Application .
4. On the Manage Content Database Settings page, in the Remove Content Database section, select the
Remove content database check box, and then click OK .
NOTE
Removing the content database does not delete the database. It only removes the association of the database with
the web application.
5. Repeat steps 3 and 4 for each content database that you want to move.
4. To detach the content databases from SQL Server
1. Verify that the user account that is performing this procedure is a member of the db_owner fixed database
role on the database server where each database is stored.
2. In SQL Server Management Studio, open the source SQL Server instance, and then expand the Databases
node.
3. Right-click the content database, point to Tasks , and then click Detach . Repeat this step for each content
database that you want to move.
NOTE
Use this procedure to move only content databases. Do not detach any other kinds of databases.
NOTE
Verify that the name is correct. If it is not, a new database will be created.
7. Specify the authentication method for the database, and then click OK .
8. Repeat these steps for each database that you are adding. Be sure that you select the correct web application
from the Web Application menu for each database.
8. To restart timer jobs by using Central Administration
1. Verify that the user account that is performing this procedure is a member of the Farm Administrators
group.
2. In Central Administration, in the Monitoring section, click Check Job Status .
3. For each scheduled job that you disabled previously, click the job to open the Edit Timer Job page, click
Enable , and then click OK .
NOTE
If you are moving a content database to a different farm, you must make the server farm account a member of the
Administrators group on the database server during the restore process. This enables the account to replicate the security
setting for the databases. This access level can be removed after the content database is moved.
The destination farm must be running the same version or a later version of SharePoint Server than the source
farm is running.
1. To record which content databases are associated with each web application
1. Verify that you have the following memberships:
securityadmin fixed server role on the SQL Server instance.
db_owner fixed database role on all databases that are to be updated.
Administrators group on the server on which you are running the PowerShell cmdlets.
The dbcreator and securityadmin fixed server roles on the destination server, in order to attach the
database and configure SQL Server logins.
An administrator can use the Add-SPShellAdmin cmdlet to grant permissions to use SharePoint Server
cmdlets.
NOTE
If you do not have permissions, contact your Setup administrator or SQL Server administrator to request
permissions. For additional information about PowerShell permissions, see Add-SPShellAdmin.
NOTE
We recommend that you use Microsoft PowerShell when performing command-line administrative tasks. The Stsadm
command-line tool has been deprecated, but is included to support compatibility with previous product versions.
NOTE
If you do not have permissions, contact your Setup administrator or SQL Server administrator to request
permissions. For additional information about PowerShell permissions, see Add-SPShellAdmin.
Where:
<http://WebApplicationURL> is the Web application associated with the content database that you are
moving.
<c:\timerjobfile.txt> is the location of the file that you are creating that lists all timer jobs associated with the
Web application.
For more information, see Get-SPTimerJob, Out-File, ForEach-Object, Get-Content, and Disable-SPTimerJob.
NOTE
We recommend that you use Microsoft PowerShell when performing command-line administrative tasks. The Stsadm
command-line tool has been deprecated, but is included to support compatibility with previous product versions.
3. To detach content databases from a web application by using PowerShell
1. Verify that you have the following memberships:
securityadmin fixed server role on the SQL Server instance.
db_owner fixed database role on all databases that are to be updated.
Administrators group on the server on which you are running the PowerShell cmdlets.
The dbcreator and securityadmin fixed server roles on the destination server, in order to attach the
database and configure SQL Server logins.
An administrator can use the Add-SPShellAdmin cmdlet to grant permissions to use SharePoint Server
cmdlets.
NOTE
If you do not have permissions, contact your Setup administrator or SQL Server administrator to request
permissions. For additional information about PowerShell permissions, see Add-SPShellAdmin.
Dismount-SPContentDatabase "<ContentDB>"
> [!NOTE]
> If you have multiple content databases that have the same name, you must use the content database GUID in
this command instead of using the content database name. To retrieve the GUID of the content database, run the
**Get-SPContentDatabase** cmdlet without arguments.
> [!NOTE]
> We recommend that you use Microsoft PowerShell when performing command-line administrative tasks. The Stsadm
command-line tool has been deprecated, but is included to support compatibility with previous product
versions.
NOTE
Use this procedure to move only content databases. Do not detach any other kinds of databases.
NOTE
If you do not have permissions, contact your Setup administrator or SQL Server administrator to request
permissions. For additional information about PowerShell permissions, see Add-SPShellAdmin.
Where:
> [!NOTE]
> We recommend that you use Microsoft PowerShell when performing command-line administrative tasks. The Stsadm
command-line tool has been deprecated, but is included to support compatibility with previous product
versions.
NOTE
If you do not have permissions, contact your Setup administrator or SQL Server administrator to request
permissions. For additional information about PowerShell permissions, see Add-SPShellAdmin.
Where: _\<c:\timerjobfile.txt\>_ is the location of the file that you created that lists all of the timer
jobs associated with the Web application.
> [!NOTE]
> We recommend that you use Microsoft PowerShell when performing command-line administrative tasks. The Stsadm
command-line tool has been deprecated, but is included to support compatibility with previous product
versions.
See also
Concepts
Move all databases in SharePoint Server