Redigeeri

Quickstart: Chat with the @mssql participant (ask mode)

The @mssql chat participant brings schema-aware SQL assistance into your GitHub Copilot Chat conversations. In ask mode, you have a natural-language conversation with @mssql about your connected database: explore tables and relationships, write Transact-SQL (T-SQL) queries, generate migrations, and get explanations of existing objects. Ask mode is read-only. It answers questions and proposes code, but never modifies files.

Tip

Use ask mode when you need an answer or a one-shot query. Use agent mode for multi-step workflows that involve tool execution. Use edit mode when you need targeted changes to specific files.

Key takeaways

  • @mssql in ask mode is schema-aware when you have an active database connection.
  • The chat participant reads schema metadata (tables, columns, relationships) and includes it in each request.
  • Ask mode is conversational and stateless. Each message is a new question.
  • Your custom instructions apply to every ask mode response.

Prerequisites

Make sure you're connected to a database and have an active editor window open with the MSSQL extension. When you connect, the @mssql chat participant understands the context of your database environment and can give accurate, context-aware suggestions. If you don't connect to a database, the chat participant doesn't have the schema or data context to provide meaningful responses.

The following examples use the AdventureWorksLT2022 sample database, which you can download from the Microsoft SQL Server Samples and Community Projects home page.

For best results, adjust table and schema names to match your own environment.

Make sure the chat includes the @mssql prefix. For example, type @mssql followed by your question or prompt. This prefix ensures that the chat participant understands you're asking for SQL-related assistance.

Chat with the @mssql participant

Use @mssql in GitHub Copilot Chat to bring intelligent, context-aware assistance into your SQL development workflow. Whether you're writing queries, exploring schema, or generating migration scripts, GitHub Copilot tailors responses to your connected database.

Here are common use cases and examples.

List or explore objects in your database schema

Ask questions about tables, columns, schemas, and object metadata.

Group objects by type

Show all objects in the `SalesLT` schema of my current database, grouped by type.

List columns and properties of a table

List the columns, data types, and nullability of the `SalesLT.Customer` table.

Count tables, views, and procedures in a database

How many tables, views, and procedures are defined in my current database?

Write queries

Get help writing common SQL queries for filtering, aggregation, and joins.

Return a list of customers based on recent orders

Write a T-SQL query to list all customers from `SalesLT.Customer` who placed
an order in the last 30 days based on the latest order date.

Calculate average order total per customer

Generate a query that calculates the average order total per customer
from the `SalesLT.SalesOrderHeader` table, sorted descending.

Update a query with another column

Update the previous query to include the full name of each customer
from the `SalesLT.Customer` table.

Explain relationships or concepts

Ask for simplified explanations of schema relationships, query logic, or T-SQL features.

Describe foreign key relationships between tables

Describe the foreign key relationship between `SalesLT.SalesOrderHeader`
and `SalesLT.Customer` tables in my current database.

Explain table relationships and keys involved

I'm a developer new to T-SQL. Explain how `SalesLT.SalesOrderHeader` is
related to `SalesLT.Customer`, and what keys are involved.

Explain vector data types and usage options

Explain how vector data types work in SQL Server and when to use them
for artificial intelligence (AI) scenarios.

Generate migration or integration code

Request help generating SQL or object-relational mapping (ORM) migration scripts.

Add a foreign key constraint to a table

Create a T-SQL script to add a foreign key constraint on
`SalesLT.SalesOrderDetail.ProductID` referencing `SalesLT.Product.ProductID`.

Generate a migration script to add a foreign key

Generate a Sequelize migration to add a foreign key from
`SalesLT.SalesOrderDetail.ProductID` to `SalesLT.Product.ProductID`,
assuming both columns exist.

For object-relational mapping (ORM) examples across Entity Framework, Prisma, SQLAlchemy, and other frameworks, see Object-relational mapping integrations with GitHub Copilot.

Ask mode vs. agent mode: which to use

Scenario Best mode
"What does this stored procedure do?" Ask mode
"Write a query to find orders over $500" Ask mode
"Connect to my LocalDev profile and list databases" Agent mode
"Add audit columns to every table in the Sales schema" Agent mode
"Design a full data model from my PRD" Plan mode

Share your experience

To help us refine and improve GitHub Copilot for the MSSQL extension, use the following GitHub issue template to submit your feedback: GitHub Copilot Feedback

When submitting feedback, consider including:

  • Scenarios tested: Let us know which areas you focused on, for example, schema creation, query generation, security, localization.

  • What worked well: Describe any experiences that felt smooth, helpful, or exceeded your expectations.

  • Issues or bugs: Include any problems, inconsistencies, or confusing behaviors. Screenshots or screen recordings are especially helpful.

  • Suggestions for improvement: Share ideas for improving usability, expanding coverage, or enhancing GitHub Copilot's responses.