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:
- Copy the mdf file and ldf file of the database.
- Browse the Microsoft SQl Server Data folder: Open C:\ and then (Program Files) then (Microsoft SQL Server) then (MSSQL.1) then (Data)
- Verify the path in the address bar: C:\Program Files\Microsoft SQL Server\MSSQL.1\MSSQL\Data
- Now paste the mdf and ldf file of the database which you want to attach.
- Now open sql server management studio with administrator privilege .
- Connect with LocalHost server and right click on the database.
- Select Attach menu from right click options
- A dialog will be opened as shown in the picture below:how to attach a database to sql server 2005
- Now click on add button as shown in the above picture and select your mdf file and click ok.
- 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. 🙂