Replace a Database in SSMS – SQL Instructions

Target Audience: Basic User, Advanced User, IT Manager
Article #: 13165


There may come a time when you need to replace a database in Microsoft SQL Server Management Studio (SSMS). Follow the instructions in this article to replace an older version with an updated database.


Create a backup of the database that will be replaced.


  1. Log into SSMS and navigate to the old database.
  2. Get the path to this database:
    a. Right click on its Properties.
    b. Go to Files.
    c. Copy the path from Files and save the location for later use.
Locate and save the path to the database to be replaced.
  1. Right-click on the old database again and select Tasks -> Detach.
Detach the old database
  1. Check the Drop Connections box and hit OK.
Confirm that you want to detach the file.
  1. Place the new database and database log file into the same location (path) as the old file, using the path you saved in Step 2.
Place new database and log file in the same location as the old one.
  1. Locate the new database file in SSMS and right-click on it and then click Attach.
Attach the new file to SSMS
  1. In the menu that opens up, click Add. This will bring up the list of databases within the path from Step 2.
  2. Click on the new database in the Locate Database Files window and then click OK.
Locate the new database and confirm its path.
  1. Once the Locate Database Files window closes, the Attach Databases window will show the details for the .mdf and .log files. Click OK to complete database’s addition.
Attach Databases window showing details of new database.
  1. To confirm success, open the newly added database and confirm that it contains the correct data.
The new database opened.

Additional Comments

Tested with SQL Express 2019 running on Windows 11.

If you need further assistance, please contact us.


Was this article helpful?

Related Articles