How to: Disconnect from Databases

You might want to disconnect from a database for several reasons: to minimize the number of active connections to the server; because you want to keep working without access to a database connection; because you set a query option to disconnect after execution; or because you are switching connections between database servers. Even if you are disconnected from a database, you can still edit a script or a query in the Transact-SQL editor. To complete these procedures, you must have an active Transact-SQL editor session that is connected to a database.

To disconnect from a database in the Transact-SQL editor

  • On the Data menu, point to Transact-SQL Editor, point to Connection, and click Disconnect.

    The editor session disconnects from the database. The window title changes to read "QueryName.sql - Disconnected", and the property browser shows the connection status as "Disconnected".

To disconnect from a database using the shortcut menu

  • Right-click in the Transact-SQL editor, point to Connection, and click Disconnect.

    The editor session disconnects from the database. The window title changes to read "QueryName.sql - Disconnected", and the property browser shows the connection status as "Disconnected".

To disconnect from a database using the toolbar

  • On the Transact-SQL Editor toolbar, click Disconnect.

    The editor session disconnects from the database. The window title changes to read "QueryName.sql - Disconnected", and the property browser shows the connection status as "Disconnected".

See Also

Tasks

How to: Connect to Different Databases in the Same Editor Session

How to: Start the Transact-SQL Editor