Forum Discussion
Attach Database MDF and LDF files using SSMS
I'm trying to restore a database with MDF and LDF files. On my old C drive I have located 4 MDF and 4 LDF files all saved at the same time. File names include "mastlog","modellog","HOPE_WW2" and "MSDBLog". I don't know if I need to copy over just the "HOPE_WW2" MDF and LDF files or all 8 files? When I am on the "Attach Databases" screen using SSMS it has a "Databases to attach" and a "Associated Files" section. Do I attach one or all four MDF files in the "Databases to attach" section? Do I attach one or all four LDF files in the "Associated Files" section? Do I need to make any changes in the connection properties section? Thanks for the support
1 Reply
- petevernBrass Contributor
When setting up a new SQL Server instance, the master, model, and msdb databases are already created, as these are system databases. Unless it’s absolutely necessary (e.g., restoring an entire instance), you should focus on restoring the user databases—in this case, HOPE_WW2.
To attach the HOPE_WW2 database, use the Attach Database Wizard in SSMS and specify the MDF file (data file) and the LDF file (transaction log file).
Here’s a summary of what the system databases store:
- master: Contains server-level metadata.
- model: Serves as a template for creating new databases.
- msdb: Stores information for SQL Server Agent jobs, alerts, and backups.
If you need to restore these system databases, attaching them won’t work—you’ll need a valid backup.
- For model and msdb, you’ll need to overwrite the existing databases created during the SQL Server installation.
- For master, SQL Server must be started in single-user mode before you can restore it.