How To Attach Data Bases SQL server 2005

SQL Server 2005 Books Online (November 2008)
How to: Attach a Database (SQL Server Management Studio)

This topic describes how to attach a database. Attaching a database places it in exactly the same state that it was in when it was detached.

Security Note: We recommend that you do not attach or restore databases from unknown or untrusted sources. Such databases could contain malicious code that might execute unintended Transact-SQL code or cause errors by modifying the schema or the physical database structure. Before you use a database from an unknown or untrusted source, run DBCC CHECKDB on the database on a nonproduction server and also examine the code, such as stored procedures or other user-defined code, in the database.

  1. In SQL Server Management Studio Object Explorer, connect to an instance of the Microsoft SQL Server Database Engine, and then expand that instance.

  2. Right-click Databases and click Attach.

  3. In the Attach Databases dialog box, to specify the database to be attached, click Add; and in the Locate Database Files 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; for example:

    C:\Program Files\Microsoft SQL Server\MSSQL.1\MSSQL\DATA\AdventureWorks_Data.mdf

    ms190209.note(en-US,SQL.90).gifImportant:
    Trying to select a database that is already attached generates an error.

  4. Optionally, to specify a different name for the database to attach as, enter the name in the Attach as column of the Attach Databases dialog box.

  5. Optionally, change the owner of the database by selecting a different entry in the Owner column.

  6. When you are ready to attach the database, click OK.

    ms190209.note(en-US,SQL.90).gifNote:
    A newly attached database is not displayed in the Databases node of Object Explorer until the view is refreshed. To refresh the view at any time, click in Object Explorer, and then click Refresh on the View menu.

  • 0 Users Found This Useful
Was this answer helpful?

Related Articles

How to Detach a Database (SQL Server Management Studio)

SQL Server 2005 Books Online (November 2008) How to: Detach a Database (SQL Server Management...

Sql 2008 R2 Management

FIX: A fix is available for SQL Server Management Studio 2008 R2 that enables you to rename SQL...

How To create Sql Data Base In Plesk

To create a database in Plesk: 1. Login to Plesk. 2. Click on the domain name in the list at...

How to connect to the MySQL database

Configuration Settings:Host = localhost (really, put localhost)Database name =...

How to connect to the MySQL server remotely

Note: If connecting from your home computer, you need a MySQL client like Navicat, phpMyAdmin, or...