Muistiinpano
Tämän sivun käyttö edellyttää valtuutusta. Voit yrittää kirjautua sisään tai vaihtaa hakemistoa.
Tämän sivun käyttö edellyttää valtuutusta. Voit yrittää vaihtaa hakemistoa.
The Chat window for GitHub Copilot in SQL Server Management Studio (SSMS) enables enhanced AI-assisted database administration and development in SSMS, helping you be more productive and efficient when working with your SQL database. Currently, the chat window only executes SELECT queries (read-only).
In this article, you learn about using GitHub Copilot Chat in SSMS, a fully integrated AI-powered chat experience from GitHub Copilot that exists directly in SSMS. It enables you to get Transact-SQL (T-SQL) support, including syntax and context-specific help, without leaving the SSMS UI. Use the chat interface to submit your question as prompt and provide intent for better scoped answers.
Why use GitHub Copilot Chat in SSMS?
GitHub Copilot Chat provides AI assistance to help you make informed decisions about your SQL database and write better T-SQL faster. With an integration in SSMS that includes connection context and schema understanding, GitHub Copilot Chat understands what you're working on and can help with tasks including:
T-SQL assistance:
- Get context-specific code suggestions and recommendations
- Understand and document what a query does
- Get assistance fixing syntax errors in your query
- Refactor queries
Database administration:
- Get help managing settings, security, and more
- Configure and monitor database maintenance
- Implement new SQL features
Database development:
- Schema design
- Data type selection
- Indexing recommendations
Prerequisites
To use GitHub Copilot Chat in SSMS, you need SSMS 22 or a later version, and a GitHub account with Copilot access. Otherwise, you can use Use GitHub Copilot for free in SQL Server Management Studio.
Use Copilot Chat in SSMS
Ask database and T-SQL questions in natural language and GitHub Copilot Chat answers them in the context of your database and its connection.
There are two places you can ask Copilot these questions; in the chat window, or directly inline in the code that you're looking to modify, using inline chat. For questions where you want to modify or add to the SQL file open in the editor, the inline chat view might work best. Use the chat pane for answers to general T-SQL questions.
To improve Copilot chat results, learn how to use slash commands, reference files, and threads to get better answers with scoped context in Copilot Chat.
Ask questions in the chat window
The chat window of Copilot Chat in SSMS enables you to ask your questions and see answers in the chat pane. It's usually the preferred way to work with Copilot for database help and general T-SQL questions.
- Open a query editor window and connection to your database.
- In SSMS, select View > GitHub Copilot Chat.
- Use the example starter prompts in the chat window to start exploring Copilot Chat, or type in a prompt and select Enter or Send to submit your question.
- If Copilot Chat offers a T-SQL suggestion you want to use, select Apply to apply the code to the active query editor, Copy code block to copy the suggestion, or Add to new file to insert the code suggestion in a new file.
- If you ask for help with understanding your code, the Insert in new file option isn't available.
- If you select Apply, the code suggestion is applied to the active editor in the diff view pattern. You can review and refine what is being proposed and apply it using Tab, or discard it using Alt+Delete.
Ask questions in the inline chat view
The inline chat view of Copilot Chat in SSMS enables you to ask your questions and see answers inline with the code directly in the editor window. With inline chat, you don't have to go back and forth to the chat window. You might find it easier to work with Copilot on questions that add to or update a currently open SQL file using inline chat.
- In SSMS, select Alt+/ to bring up the inline chat view of Copilot Chat in the editor.
- Type your T-SQL related question in the Ask Copilot text box, and then select Enter or Send to ask your question.
- Code suggestions from Copilot Chat appear in the diff view. You can review and refine what is being proposed and apply the change to your code using Tab, or discard it using Alt+Delete.
- You can promote your inline chat thread to the chat window by selecting View in chat window. Promoting the chat to the window preserves the record and context of your conversation, and you can continue in the chat window.
- Select Esc to close the inline chat view.
Note
Queries from GitHub Copilot in SSMS are executed under the context of the user's login and permissions, whether from the chat window or inline chat view. There are no separate permissions for GitHub Copilot in SSMS.
Create threads for separate conversations
As you ask questions and send prompts in a chat session, Copilot uses the history of chat prompts and responses. The previous prompts and responses provide context to your current chat prompt. This means that you can ask follow-up questions or clarify your previous question without having to repeat the context. For example, you can ask "How do I change the compatibility mode?", "What are the differences between compatibility mode 140 and 170?", "What do I need to consider when changing compatibility mode?", and more.
To start over with a new chat session and discard the current context, select Delete thread. Select Create new thread or Ctrl+N in the chat window to start a new thread. New threads are useful when you want to move to a different topic and avoid the previous context and history. Use threads to keep conversations focused on the task at hand, and keep the context clear so the answers are based on relevant history.
Switch chat thread
You can toggle between multiple ongoing threads to provide the right historical context for your question. Use Ctrl+Page Down for previous thread or Ctrl+Page Up for next thread in the chat window. Ctrl+Shift+T expands the thread dropdown list.
Preserve the inline chat
To preserve the history of your inline chat, promote it to the chat window. Select View in chat window to maintain a record and context of the conversation, and continue in the chat window.
Preview Markdown content
You can preview any Markdown content generated by Copilot Chat directly in the Markdown editor. When Copilot Chat generates Markdown content, select the Preview button in the upper-right corner of the chat window to see a rendered preview. You can edit and save the Markdown content as needed. This feature is helpful when you want to quickly visualize and work on Markdown files without manually copying and pasting.
Generate Mermaid diagrams
Copilot Chat can generate Mermaid diagrams, including entity relationships, flowcharts, Gantt, and more. You can then visualize complex relationships and workflows directly in the editor.
For example, you might use one or more of the following prompts:
Visualize the relationships between tables in this database as a Mermaid diagramVisualize the relationships between tables in the Orders schema of this database as a Mermaid diagramCreate a Mermaid flowchart for the steps to change the compatability mode
Copilot uses your active query editor and any references you add to gather context, and then returns the Mermaid syntax in the chat window. Select Preview to open a new Markdown file and view the diagram. You can save or share the Markdown or rendered chart for future use.
Tip
You can use the Markdown preview controls to switch between preview modes and zoom in on complex Mermaid diagrams.