SCCMSQL Server

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.

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.

Stop all Configuration Manager services

Run the command prompt as administrator. Type preinst.exe /STOPSITE and hit enter key.

Stop all Configuration Manager services

All the Configuration Manager services are stopped in order. Wait until you see the line All site services are stopped.

Stop all Configuration Manager services

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.

Find the SCCM Database Location

Under the database properties, click Files. On the right pane, look for the database path and log file path.

Find the SCCM Database Location

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.

Move the SCCM Database to another drive

On the Detach Database box, check the box “Drop Connections“. Click OK.

Move the SCCM Database to another drive

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
Move the SCCM Database to another drive
Move the SCCM Database to another drive

Go to the destination drive and verify the SCCM database file and log file.

Move the SCCM Database to another drive

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.

Attach the Database

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.

Attach the Database

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 TRUSTWORTHYON

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.

Set Database Readonly False

Right click SCCM database and run the below query.

EXEC sp_changedbowner 'sa'

Change database owner to 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.

Prajwal Desai

Hi, I am Prajwal Desai. For last few years I have been working on multiple technologies such as SCCM / Configuration Manager, Intune, Azure, Security etc. I created this site so that I can share valuable information with everyone.

Related Articles

7 Comments

  1. 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.

  2. 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

Leave a Reply

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

Back to top button