Attach a database

Last modified: June 12, 2025

You can attach a database in the AI Assistant tool window to give the LLM access to the database schema and metadata. This can improve the quality of generated SQL queries and AI responses.

Note

  • You can attach only one database at a time. To switch databases, detach the current database and attach a new one. For better accuracy, it’s recommended to start a new chat when changing the database context.

  • When you attach a database, the assistant retrieves only the data structure information and does not access the actual data. The assistant does not modify the structure or add comments to the properties of database objects.

To attach a database:

1. In the AI Assistant chat window, click Attach Database below the message input box.

2. In the dialog that opens, select one of the following options:

  • Select Connection — This option allows you to select a server and database from the Database Explorer connection pool.

Select a connection and database to attach by clicking Select Connection.

  • Database Explorer — The current active connection is displayed under Database Explorer.

Click the connection name to attach its default database.

  • Document Window — The open SQL documents are displayed under Document Window.

Click a document to attach the database it uses.

Note

The Database Explorer option is unavailable if no connection is open in Database Explorer. The Document Window option is unavailable if no SQL document is open.

Attach database schema

A notification appears confirming the successful attachment of the database, and the name of the attached database is displayed in the message input box.

Note

Attaching a database improves the accuracy of AI Assistant context menu actions, such as Explain SQL, Optimize SQL, and Fix SQL.

Detach a database

To detach a database, right-click its name below the message input box and select Detach.

Detach database