Trying to restore database using MDF? Here’s how we do it.
Restoring a database from a .BAK file is a simple task from Microsoft SQL management studio. Restoring the database only from .mdf is confusing for the database user.
At Bobcares, we often get requests to restore an MSSQL database as a part of our Server Management Services.
Today, let’s have a look at how to restore a database using only .mdf file and see how our Support Engineers fix it.
What is .MDF and .LDF files
MDF file is the primary data file that contains all the data and schema. LDF File is the Log data file and contains all the database transaction logs
If .bak file is not available and MDF and LDF files are available. We can still restore the database from the .MDF and .LDF files. Also we can restore only from .MDF files.
Recently we had a customer who was confused about how to restore the database only from the single MDF file. Let’s discuss how our Support Engineers helped him to restore the database from the available files.
How we restore a database with MDF without LDF file
Similarly, let’s discuss how our Support Engineers restore a database if only .MDF file is available.
Open Microsoft SQL Management Studio >> Right Click on Databases >> Click on Attach >> Click Add button
Browse the location of your MDF File >> select the file >> click on OK
LDF “not found” entry is show by default. Therefore we will need to remove the LDF entry manually.
Select the LDF file and Click Remove.
Click on OK. While attaching the database, SQL Server will automatically create a new LDF file.
Once the process is completed. Restart the SQL service.
Common error during restoration and how we fix it.
Let’s discuss how our Support Engineers fix the common error faced during restoration.
Restore failed for server “database name”
The common error is “Restore failed for server database name”. If the error pops up after the final steps. The database files were not able to overwrite the existing files.
To resolve the error we create a new database with a different name and attach the MDF file. Also, the MDF file need to be renamed to a different name before restoring the files,
[Need any further assistance to fix MSSQL errors? – We’ll help you]
Conclusion
In short, we have discussed how our Support Engineers restore the database with .MDF and .LDF file. Also, we saw how our Support Engineers resolve the common error that arises when restoring a database from MDF and LDF files.
0 Comments