MDF files contain all SQL Server database information. The LDF file you see alongside the MDF file is an archive of the server logs. When you move your database to a new computer, the MDF and LDF files are "re-attached." "Attaching" a database means you restore and load the associated files on the database server. The SQL Server attaches MDF and LDF files using the "sp_attach_db" stored procedure.
- Skill level:
Other People Are Reading
Click the Windows "Start" button and select "All Programs." Click your "SQL Server" program group and click the "SQL Server Management Studio" shortcut. This opens the Management Studio console application.
Click the SQL Server name on the left side of your console. In the main toolbar, click "New Query." This opens a query window where you execute the "sp_attach_db" stored procedure.
Type the following command into your query console:
The first parameter is the "Database_Name." This is the name of the database that registers with SQL Server. This can be the original name of the backed up database, or you can give it a new name. The second parameter is the location and file name for the MDF file. The third is the location for the LDF file. You can restore from the local hard drive, an external drive or a shared network location.
Press the "F5" key. This executes the SQL statement and restores the database along with the log file.
- 20 of the funniest online reviews ever
- 14 Biggest lies people tell in online dating sites
- Hilarious things Google thinks you're trying to search for