How to Attach Databases in SQL Server

Let's see how to attach a database or multiple databases in SQL Server.

Attaching databases in SQL Server is quite simpler and can be bone in just a couple of clicks. SQL Server 2008 R2 version was used for this article, though the version doesn't matter because the procedure to attach the databases are all the same in SQL Server versions so far. Also, the Northwind and Pubs databases were used for this article; they are freely available and can be downloaded from the Microsoft website.


Open SSMS and login with administrative credentials. Navigate to the Object Explorer window and right-click on the "Databases" node and select "Attach".


That will open the Attach Databases window.


Through this window we will add and attach databases. Click on the "Add" button that will open the file directory window from which we need to locate the databases.


Once the database files or .mdf files have been added you can generate the Create database script or schedule as a job to execute later.


We can even change the database owner from the Owner lists available. Now just hit "OK". The database will be created successfully; you can view the Object Explorer to see the created databases.


See, there are barely three to four steps here that we performed to attach the databases. Hope you like it. Thank you!

Similar Articles