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:
- Expand the registered SQL server
- Right-click Databases, select All Tasks -> Attach Database…
- Click the “…” button to browse for the .mdf file
- Highlight the necessary .mdf file and click OK
- 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:
- First, you’ll need to navigate to the Query Analyzer by going to the Start menu -> All programs -> Microsoft SQL Server -> Query Analyzer
- In the dialogue box marked “Connect to SQL Server” enter the name of your SQL Server as well as your Login name and Password
- Click the OK button
- 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.
- View the Contents of a Table in a SQL Server Database Using Enterprise Manager
- Create a MySQL Backup from Command Line – MySQL Import SQL File
- How to Install SQL Server 2012 Express on Windows Server 2012
Don’t see what you’re looking for? Use the search bar at the top to search our entire Knowledge Base.
The Hivelocity Difference
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.