Forum Discussion
TimB
Jan 18, 2025Copper Contributor
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 "MSD...
petevern
Jan 25, 2025Brass 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.