Attaching a Database

This topic describes how to attach a database by using dbForge Studio for SQL Server. You can use this feature to copy, move, or upgrade a SQL Server database.

Attaching a database

You can attach a copied or detached SQL Server database. When you attach a database, all data files (MDF and NDF files) must be available. If any data file has a different path from when the database was first created or last attached, you must specify the current path of the file.

You can’t attach a database in the following cases:

  • A database created by a more recent version of SQL Server cannot be attached in earlier versions.
  • Attempting to attach a database that has not been detached will return an error.
  • Trying to select a database that is already attached generates an error.

To attach a database:

  1. Use Database Explorer to connect to the instance of the SQL Server database engine and then expand the instance.
  2. Right-click the instance, and then click Attach Database.
  3. In the Attach Database dialog box, click the Add button to specify the database to be attached.
  4. In the Browse For Folder dialog box, select the disk drive where the database resides and expand the directory tree to find and select the .mdf file of the database. Note, you can select several *.mdf files to attach.
  5. Optionally, specify a different name for the database to attach as.
  6. Optionally, you can select a different owner.
  7. Optionally, you can remove the selected file from the databases to attach grid by clicking the Remove button.
  8. Click OK.