[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 375
  • Last Modified:

recover from mdf files

i have SQL cluster server which failed because of hardware.
i couldnt rebuild the master even with rebuild.exe
so i had to delete the sql cluster and create again
i have the only mdf and ldf files of the old server.
is there a way to recover the master and other database from mdf and ldf and post to the new server.

any help will be highly appreciated.


  • 2
  • 2
  • 2
  • +1
3 Solutions
Irwin SantosComputer Integration SpecialistCommented:
What I have done in the past was copy the databases into the MDF/LDF folders..and voila it worked!

But I'm not sure about the master....  if this is a fresh install...backup would be prudent before you apply my voodoo fix.
Aneesh RetnakaranDatabase AdministratorCommented:
Hi Stavros26,

Do u have the  backup of the master database

1. Stop MSSQLServer and SQLServerAgent services.
2. From a command prompt, enter this command

sqlservr.exe -m

3. then run the following script
USE master


     FROM DISK = ''c:\path\backup\master.bak'

Aneesh RetnakaranDatabase AdministratorCommented:
Moving the master database
1. Change the path for the master data and log files in SQL Server Enterprise Manager.

Note You may also change the location of the error log here.
2. Right-click the SQL Server in Enterprise Manager and then click Properties.
3. Click Startup Parameters to see the following entries:-dD:\MSSQL7\data\master.mdf
-d is the fully qualified path for the master database data file.

-e is the fully qualified path for the error log file.

-l is the fully qualified path for the master database log file.
4. Change these values as follows: a.  Remove the current entries for the Master.mdf and Mastlog.ldf files.
b.  Add new entries specifying the new location:-dE:\SQLDATA\master.mdf
5. Stop SQL Server.
6. Copy the Master.mdf and Mastlog.ldf files to the new location (E:\Sqldata).
7. Restart SQL Server.
Get quick recovery of individual SharePoint items

Free tool – Veeam Explorer for Microsoft SharePoint, enables fast, easy restores of SharePoint sites, documents, libraries and lists — all with no agents to manage and no additional licenses to buy.

do fresh installation of your sql server on the cluster.

1.stop the sql server services
2.replace the new mdf and ldf files with the old one you have
3.start the sql server services
You cannot attach system databases and follow as suggested above to attach user databases. KBA http://support.microsoft.com/default.aspx?scid=kb;en-us;224071 fyi.

hi SatyaSKJ ,
you can do it provided that all the configuration of the server is same. it have tried it and it worked for me.
 it is similar to restoring backup.
and if the current installation of sql server is same as what you had before you can simply replace the files and it will work.
One more thing no need for sp_attach or detach just replace files.
But that is not a recommended way to recovery from a disaster, backup is always a saviour.

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

  • 2
  • 2
  • 2
  • +1
Tackle projects and never again get stuck behind a technical roadblock.
Join Now