Move SCCM Database to Another Drive
In this post I will cover the procedure to move the SCCM database to another drive. I will be moving the Configuration Manager database from C:\ drive to another drive on same server.
My lab setup is simple, the SCCM and SQL server are installed and running on same server. I am currently running Configuration Manager version 1910.
When I logged in to my lab today, I noticed that I didn’t have much free space left on my C: drive. And since long time I always wanted test the SCCM database move from C: drive to another drive. So I think this is the right time to do this. Let’s get started.
First of all, you must backup your Configuration Manager server before moving the database to other drive. Also have a rollback plan if something goes wrong during database move process.
Table of Contents
Step 1 – Stop All Configuration Manager services
Using the Hierarchy Maintenance tool stop all Configuration Manager services at a site without having to stop services individually.
Locate the Preinst.exe application. You can find Preinst.exe in the <SCCM Installation path>\bin\X64\00000409 on the site server. You can also find the file here – \<SiteServerName>\SMS_<SiteCode\bin\X64\00000409.
Run the command prompt as administrator. Type preinst.exe /STOPSITE and hit enter key.
All the Configuration Manager services are stopped in order. Wait until you see the line All site services are stopped.
Step 2 – Find the SCCM Database Location
If you are not sure about the location of your SCCM database, you can find that out from database properties. Launch SQL server management studio and connect to database engine.
Right-click Configuration Manager database and click Properties.
Under the database properties, click Files. On the right pane, look for the database path and log file path.
Step 3 – Move the SCCM Database to Another drive
In this step we will first detach the SCCM database. Detaching a database removes it from the instance of SQL Server but leaves the database intact within its data files and transaction log files.
Right click SCCM database and click Tasks > Detach.
On the Detach Database box, check the box “Drop Connections“. Click OK.
Finally use the below command to move the SCCM database from C:\ drive to another drive which is E:\ in my case. Create a new folder within the new drive, for example SQLDB.
Replace the CM_P01 with your site code.
Copy "C:\Program Files\Microsoft SQL Server\MSSQL14.MSSQLSERVER\MSSQL\DATA\CM_P01*.*" E:\SQLDB
Go to the destination drive and verify the SCCM database file and log file.
Step 4 – Attach the Configuration Manager Database
Now that we have moved our SCCM database to another drive, we must attach this database. In the SQL server management studio, right click Databases and click Attach.
In the Attach Databases window, click Add and browse to the drive that contains your SCCM database. Select the Database. The database and log file should appear under Database Details. Click OK.
Notice that the database shows Read-Only. Right click SCCM database and run the below query.
Note – After you move the SCCM database, if you don’t set the SQL TRUSTWORTHY property to ON, <ConfigMgr_Install>\bin\x64\CryptoUtility.dll fails to load into SQL Server, and you receive the “invalid cursor state” error message.
ALTER DATABASE CM_P01 SET TRUSTWORTHY
ON
Next, go to SCCM database properties and click Options. Set the drop-down for Database Read-Only and change it from True to False. Click OK.
Right click SCCM database and run the below query.
EXEC sp_changedbowner 'sa'
Ensure that Isolation Level is set to read committed snapshot by running the below query.
DBCC USEROPTIONS
Finally you can either start SCCM Services using Service Manager or restart the server. Congratulations you have successfully moved the SCCM database to another drive.
Thank you Prajwal Desai!
Procedure worked excellent now on SCCM 2211.
Thank you,
Ovidiu
What about the reporting services? When you have the DB on a separate server what is recommended for Reporting?
Howdy! Are the steps the same for moving the DB to a new server? Moving to latest SQL server in preparation for updating SCCM.
I wonder if I can shutdown the Sccm main server instead of Stop All Configuration Manager services?
If you shutdown you are stopping all the services. Not sure why would you want to shutdown the server ?.
I followed these steps, but I also had to Perform site maintenance or reset this site by going to cd.latest folder in the installation directory (C:\Program Files\Microsoft Configuration Manager in my environment).
1. Navigate to the ConfigMgr installation (C:\Program Files\Microsoft Configuration Manager directory), and in thecd.latest/smssetup/bin/x64folder, run setup.exe.
2. On the Available Setup Option page, select the Perform site maintenance or reset this site option, and click;Next.
Yes. I have now moved db files to other path but out main scope is to have free space on C:\. How do we safely delete the db and log files after copied to new path?
I have just deleted db and log files from c:\ and i couldn’t open up the console again. Not sure if’ve broken already
I suggest you backup site and DATA completely before do this
Is it possible to move the database to another server?
Yes you can take back up and restore in another server