Attach Databases (General Page)

Use this page to attach a user database.

Note

Each database contains a unique identifier used for routing Service Broker messages to the database. To change this identifier when attaching a database, use a CREATE DATABASE statement with a FOR ATTACH WITH NEW_BROKER clause. For more information, see CREATE DATABASE (Transact-SQL) and Managing Service Broker Identities.

To attach a database by using SQL Server Management Studio

Note

When you attach a database by using SQL Server Management Studio, you can generate the corresponding Transact-SQL CREATE DATABASE script by clicking the Script button and then selecting a destination for the script.

Options

  • Databases to attach
    Displays information about the databases selected using the Add button.

    Security noteSecurity Note

    We recommend that you do not attach or restore databases from unknown or untrusted sources. These 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.

  • <no column header>
    Displays an icon indicating the status of the attach operation. The possible icons are described in the Status description, below).

  • MDF File Location
    Displays the path and file name of the selected MDF file.

  • Database Name
    Displays the name of the database.

  • Attach As
    Optionally, specifies a different name for the database to attach as.

  • Owner
    Provides a drop-down list of possible database owners from which you can optionally select a different owner.

  • Status
    Displays the status of the database according to the following table.

    Icon

    Status text

    Description

    (No icon)

    (No text)

    Attach operation has not been started or may be pending for this object. This is the default when the dialog is opened.

    Green, right-pointing triangle

    In progress

    Attach operation has been started but it is not complete.

    Green check mark

    Success

    The object has been attached successfully.

    Red circle containing a white cross

    Error

    Attach operation encountered an error and did not complete successfully.

    Circle containing two black quadrants (on left and right) and two white quadrants (on top and bottom)

    Stopped

    Attach operation was not completed successfully because the user stopped the operation.

    Circle containing a curved arrow pointing counter-clockwise

    Rolled Back

    Attach operation was successful but it has been rolled back due to an error during attachment of another object.

  • Message
    Displays either a blank message or a "File not found" hyperlink.

  • Add
    Find the necessary main database files. When the user selects an .mdf file, applicable information is automatically filled in the respective fields of the Databases to attach grid.

  • Remove
    Removes the selected file from the Databases to attach grid.

  • "<database_name>" database details
    Displays the names of the files to be attached. To verify or change the pathname of a file, click the Browse button ().

    Note

    If a file does not exist, the Message column displays "Not found." If a log file is not found, it exists in another directory or has been deleted. You need to either update the file path in the database details grid to point to the correct location or remove the log file from the grid. If an .ndf data file is not found, you need to update its path in the grid to point to the correct location.

  • Original File Name
    Displays the name of the attached file belonging to the database.

  • File Type
    Indicates the type of file, Data or Log.

  • Current File Path
    Displays the path to the selected database file. The path can be edited manually.

  • Message
    Displays either a blank message or a "File not found" hyperlink.

Note

After you attach a SQL Server 2005 or SQL Server 2000 database to SQL Server 2008, the database becomes available immediately and is then automatically upgraded. If the database has full-text indexes, the upgrade process either imports, resets, or rebuilds them, depending on the setting of the Full-Text Upgrade Option server property. If the upgrade option is set to Import or Rebuild, the full-text indexes will be unavailable during the upgrade. Depending the amount of data being indexed, importing can take several hours, and rebuilding can take up to ten times longer. Note also that when the upgrade option is set to Import, if a full-text catalog is not available, the associated full-text indexes are rebuilt. For information about viewing or changing the setting of the Full-Text Upgrade Option property, see How to: View or Change Server Properties for Full-Text Search (SQL Server Management Studio).