A database failure always indicates the corruption of the database. To bring your SQL Server 2008 or 2008 R2 back to normal use, you need to restore your database from its MDF file in your SQL Server. To repair your SQL database, you can either use the MS SQL itself or apply EaseUS MS SQL Recovery, the accomplished SQL repair tool.
Applies To: MS SQL Server 2016, 2014, 2012, 2008/2008 R2 and older versions
As one of the best database management tools, Microsoft SQL Server is frequently used among database administrators, and the versions, SQL Server 2008 and 2008 R2, still gain widespread popularity. However, similar to using any other software, it is not without any problem while using SQL Server. One of the common issues encountered by SQL Server users is the corruption of the database, which will need you to restore the database from the MDF and LDF files in the SQL Server. Fortunately, the way to repair your database with the MDF and LDF files are quite straightforward and there are two different methods to achieve it. Apply your preferable solution and restore your SQL Server database without delay.
There are two options for you to restore MDF and LDF files to your SQL database.
You can choose to repair your SQL database with the help of SQL Server Management Studio or T-SQL.
Preparation:
Step 1. Open Microsoft SQL Server Management Studio and go to "Object Explore".
Step 2. Right-click on "Database" and choose "Attach".
Step 3. In the new window, click the "Add" button. Then search for and choose the .mdf file of the database you want to restore. Click "OK" > "OK".
Execute the following command in the management studio:
Create database dbname
On
(
Filename= 'path where you store the MDF file',
Filename ='path where you store the LDF file'
)
For attach;
If the two options above fail to restore your database from the MDF file in SQL Server, don’t be upset, you still have another choice.
Professional SQL repair tool - EaseUS MS SQL Recovery, will easily fulfill your needs of restoring the database from MDF file in SQL Server. It is especially good at restoring the corrupt database by repairing its MDF file. Besides, it also performs well in:
Now, restore your database from MDF file in SQL Server with EaseUS MS SQL Recovery:
Step 1. Stop MS SQL Server service via services.msc or Management Studio.
Step 2. Run EaseUS SQL Recovery. In the main interface, choose the MDF/NDF file of the database you want to restore. Then click "Repair" to start repairing your MDF/NDF file.
If you know the exact location of the file, click "Browse" to locate the database.
If you don't know the file location, click "Search" to search for the .mdf or .ndf file in.
Step 3. When it has done, you will see the recovered database objects listed in the left pane of the window.
Step 4. Click "Export" in the bottom right corner of the screen to save your database objects. Choose a preferred format, MDF, or SQL scripts.
On the "Export to database" window, choose "Create new database" or "Export to existing database" to save the repaired data. If you want "Create new database", enter the database name and choose an SQL location. If you select "Exporting to existing database", you need to select the existing database.
Step 5. Now restart the SQL Server.
Related Articles
[Fixed] SQL Error 945 | Database Cannot Be Opened due to Inaccessible Files
How to Restore Database in SQL Server 2014 from .Bak File
SQL Database Recovery Pending Access Denied
How to Fix A Corrupted SQL Server Transaction Log File