How to Restore a Database on SQL Server Using .mdf, .ldf and .ndf Files

To restore a database on SQL Server using .mdf, .ldf, or .ndf files, rather than performing a restore, you will actually need to attach the database. There are two ways to do this.

 

Using Enterprise Manager

To attach a database using Enterprise Manager, follow these instructions:

  1. Expand the registered SQL server
     
  2. Right-click Databases, select All Tasks -> Attach Database…
     
  3. Click the “” button to browse for the .mdf file
     
  4. Highlight the necessary .mdf file and click OK
     
  5. Click OK again

The database will now show up in Enterprise Manager

 

Using Query Analyzer

To attach a database for use in Transact-SQL, you’ll need to use the MSSQL Query Analyzer tool. If you’ve never used the Query Analyzer tool, you can follow these steps:

  1. First, you’ll need to navigate to the Query Analyzer by going to the Start menu -> All programs -> Microsoft SQL Server -> Query Analyzer
     
  2. In the dialogue box marked “Connect to SQL Server” enter the name of your SQL Server as well as your Login name and Password
     
  3. Click the OK button
     
  4. This will open an empty window where you can now enter your queries

The following is a series of sample commands based on your files above. You will need to specify the correct directory where these files exist (this example has the files in the C:\SQL directory).

EXEC sp_attach_db @dbname = N’rs_ds’,

@filename1 = N’C:\SQL\rs_ds_dat1.mdf’,

@filename2 = N’C:\SQL\rs_ds_dat3.ndf’,

@filename3 = N’C:\SQL\rs_ds_dat4.ndf’,

@filename4 = N’C:\SQL\rs_ds_dat2.ldf’

And there you have it! Using either of these methods, you now have the ability to restore a database on SQL Server.

 

Need More Personalized Help?

If you have any further issues, questions, or would like some assistance checking on this or anything else, please reach out to us from your my.hivelocity.net account -> Support and provide your server credentials within the encrypted field for the best possible security and support.

If you are unable to reach your my.hivelocity.net account or if you are on the go, please reach out from your valid my.hivelocity.net account email to us here at: support@hivelocity.net. We are also available to you through our phone and live chat system 24/7/365.

 

Additional Links:

Looking for more information on SQL Server? Search our Knowledge Base!  

In need of more great content? Interested in cPanel, Private Cloud, or Colocation? Check out our recent posts for more news, guides, and industry insights!

Share on Twitter
Share on Facebook