I only have the .mdf file backup and no SQL Server database backups. Is it possible to get my database back into SQL Server?

    Requires Free Membership to View

Referencing a similar question posted on March 28 2005

You can use the attach database function of SQL Server to attach the MDF file and create the database.

This can be done one of two ways:

1. Using Enterprise Manager

  1. Expand the Databases tree
  2. Right click and select All Tasks
  3. Select Attach Database
  4. Find and select the MDF file
  5. The GUI will display the name of the MDF and LDF files and there should be an X on the LDF file name
  6. Change the name of the database and owner as needed and select OK
  7. An error message will appear that says "Filename specified for log is incorrect. Do you want to continue", click on Yes
  8. The database should now be attached to your server. If the database came from another server you will probably need to take care of user and login mismatches.
2. Using T-SQL
EXEC sp_attach_single_file_db @dbname = 'pubs', @physname = 'c:\Program Files\Microsoft SQL Server\MSSQL\Data\pubs.mdf'

Click here for a similar tip posted March 28 2005.

Do you have comments on this Ask the Expert Q&A? Let us know.

This was first published in August 2005

There are Comments. Add yours.

TIP: Want to include a code block in your comment? Use <pre> or <code> tags around the desired text. Ex: <code>insert code</code>

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy
Sort by: OldestNewest

Forgot Password?

No problem! Submit your e-mail address below. We'll send you an email containing your password.

Your password has been sent to: