An MDF file contains all SQL Server database tables and stored procedures. The MDF file is used as a backup to archive the data saved to the database. To "convert" the MDF file back to SQL, attach it to your SQL Server database. This can be done with or without the LDF file, which is a log file that keeps the transactions executed on the database. Converting the MDF to SQL is called "attaching," and it activates the database on your server.
- Skill level:
- Moderately Challenging
Other People Are Reading
Click the SQL Server Windows "Start" button. Select "All Programs," and choose "SQL Server" from the Programs list. In your SQL Server directory, click "SQL Server Management Studio." This opens the main SQL Server console.
Click your database server name on the left side of the window. If you only have one SQL Server installed on the network, only one icon is displayed. Click your server name, then click "New Query" to open the command line.
Enter the following code into the console command line window:
sp_attach_single_file_db 'db_name', 'mdf'
Replace "db_name" with the name you want displayed on the SQL Server. The "mdf" string is the physical location of the MDF file on the hard drive.
Press the "F5" key to execute the database stored procedure and attach the MDF file the SQL Server. It may take several minutes if the MDF file is several gigabytes. The console returns a "Success" message when it is finished attaching the database file to your server.
- 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