How to attach existing database to sql server 2005

How to attach existing database to sql server 2005

Hello Friends, today I will describe how I can attach a databse from its mdf and ldf file. For this we need to follow these steps:

  1. Copy the mdf file and ldf file of the database.
  2. Browse the Microsoft SQl Server Data folder: Open C:\ and then (Program Files) then (Microsoft SQL Server) then (MSSQL.1) then (Data)
  3. Verify the path in the address bar: C:\Program Files\Microsoft SQL Server\MSSQL.1\MSSQL\Data
  4. Now paste the mdf and ldf file of the database which you want to attach.
  5. Now open sql server management studio with administrator privilege .
  6. Connect with LocalHost server and right click on the database.
  7. Select Attach menu from right click options
  8. A dialog will be opened as shown in the picture below:how to attach a database to sql server 2005how to attach a database to sql server 2005

     

  9. Now click on add button  as shown in the above picture and select your mdf file and click ok.
  10. After adding the mdf file in the above dialog click on ok button as indicated in the picture.

These are the simple steps to attach a database from its mdf and ldf file.

Now you can carry these to files anywhere to restore your database to any machine. We can also restore database from its backup file. I will explain the steps in next post.

Happy coding. 🙂

How useful was this post?

Click on a star to rate it!

Average rating / 5. Vote count:

As you found this post useful...

Follow us on social media!

We are sorry that this post was not useful for you!

Let us improve this post!

Leave a Reply to Anonymous Cancel reply

Your email address will not be published. Required fields are marked *

%d bloggers like this: