Your Webhosting Questions
Answered by the Webhosting Experts
Tags
...
...

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.

 

Popular Links

Looking for more information on MSSQL? Search our Knowledge Base!

Interested in more articles about Databases? Navigate to our Categories page using the bar on the left or check out these popular articles:

Popular tags within this category include: MySQL, MSSQL, phpMyAdmin, PostgreSQL, and more.

Don’t see what you’re looking for? Use the search bar at the top to search our entire Knowledge Base.

 

The Hivelocity Difference

Seeking a better Dedicated Server solution? In the market for Private Cloud or Colocation services? Check out Hivelocity’s extensive list of products for great deals and offers.

With best-in-class customer service, affordable pricing, a wide-range of fully-customizable options, and a network like no other, Hivelocity is the hosting solution you’ve been waiting for.

Unsure which of our services is best for your particular needs? Call or live chat with one of our sales agents today and see the difference Hivelocity can make for you.

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 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: [email protected]. We are also available to you through our phone and live chat system 24/7/365.

Tags +
...