Export (0) Print
Expand All

How to: Connect to a File-based Database 

You can attach an existing database file to a local Microsoft SQL Server instance, or create a new database file to attach to the local SQL Server instance.

NoteNote

You can only connect to Microsoft SQL Server database files or MSDE files. If you connect to an MSDE file, then its format will be changed to SQL Server 2005 database-file format.

To temporarily attach a file-based database to the local SQL Server instance

  1. Right-click the Data Connections node in Server Explorer and choose Add Connection.

    The Add Connection dialog box appears.

  2. Click the Change button.

    The Change Data Source dialog box appears.

  3. Select Microsoft SQL Server Database File and click OK.

    The Add Connection dialog box reappears, with Microsoft SQL Server Database File (SqlClient) shown in the Data source text box.

  4. Click Browse and browse to an existing .mdf file.

    If you type a file name that does not exist, a blank .mdf file will be created.

  5. Select either Use Windows Authentication or Use SQL Server Authentication.

    For more information on SQL Server database access authentication, see Create New SQL Server Database Dialog Box.

  6. Click OK.

    The new database appears in Server Explorer. It will remain connected to SQL Server until you close the connection.

NoteNote

You must have adequate Microsoft SQL Server permissions to create or attach a new database on the target server.

To permanently attach a file-based database

  1. Right-click the Data Connections node and choose Add New Connection.

    The Add Connection dialog box appears.

  2. In Server Name, type or select the path to the SQL Server instance.

    You may type "." for the default SQL Server 2005 instance on your computer, or ".\SQLEXPRESS" for the default SQL Server Express instance.

  3. Select either Use Windows Authentication or Use SQL Server Authentication.

  4. Select Attach a database file, click Browse, and open an existing .mdf file.

  5. Click OK.

    The new database appears in Server Explorer. It will remain connected to SQL Server until you explicitly detach it.

See Also

Community Additions

ADD
Show:
© 2014 Microsoft