Note
Access to this page requires authorization. You can try signing in or changing directories.
Access to this page requires authorization. You can try changing directories.
GitHub Copilot provides both inline suggestions while typing in the code editor and an interactive chat experience. You can ask the chat participant questions or provide prompts by typing @mssql
followed by your prompt.
Get started
Ensure that you're connected to a database and have an active editor window open with the MSSQL extension. This connection allows the @mssql
chat participant to understand the context of your database environment, enabling accurate and context-aware suggestions. Without a database connection, the chat participant won'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 ensures that the chat participant understands you're asking for SQL-related assistance.
Chat with the MSSQL's chat participant in Visual Studio Code
Use the @mssql
chat participant in GitHub Copilot Chat to bring intelligent, context-aware assistance into your SQL development workflow, all directly within Visual Studio Code. Whether you're writing queries, evolving your schema, or integrating with application code, GitHub Copilot can help you design and understand relational models, generate or optimize T-SQL code, create seed data, scaffold ORM migrations, and even explain business logic or security concerns using natural language, all tailored to your connected database context.
Here are common use cases and examples of what you can ask via the chat participant:
List or explore objects in your database schema
Ask questions about tables, columns, schemas, and object metadata in your database.
- Show all objects in the
SalesLT
schema of my current database, grouped by type. - List the columns, data types, and nullability of the
SalesLT.Customer
table. - How many tables, views, and procedures are defined in my current database?
Write simple queries
Get help writing common SQL queries for filtering, aggregation, and joins.
- 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. - Generate a query that calculates the average order total per customer from the
SalesLT.SalesOrderHeader
table, sorted descending. - 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 features relevant to development.
- Describe the foreign key relationship between
SalesLT.SalesOrderHeader
andSalesLT.Customer
tables in my current database. - I'm a developer new to T-SQL. Explain how
SalesLT.SalesOrderHeader
is related toSalesLT.Customer
, and what keys are involved. - Explain how vector data types work in SQL Server and when to use them for AI scenarios.
Generate migration or integration code
Request help generating SQL or ORM-based migration scripts.
- Create a T-SQL script to add a foreign key constraint on
SalesLT.SalesOrderDetail.ProductID
referencingSalesLT.Product.ProductID
. - Generate a Sequelize migration to add a foreign key from
SalesLT.SalesOrderDetail.ProductID
toSalesLT.Product.ProductID
, assuming both exist.
Use inline suggestions with GitHub Copilot
You can start by typing a T-SQL query in a new editor window, like SELECT * FROM SalesLT.Customer
, and observe the inline suggestions provided by GitHub Copilot. The suggestions will appear as you type, and you can accept them by pressing Tab
or Enter
.
Alternatively, you can type the same query, SELECT * FROM SalesLT.Customer
, directly into the editor. Then, highlight it to reveal the ✨ smart action icon, which appears next to the highlighted query. This icon provides quick access to additional GitHub Copilot options, such as Modify using Copilot
to adjust your query, /doc
to generate documentation, or the ability to ask GitHub Copilot general questions related to the query.
When you select Review using GitHub Copilot, you see an inline recommendation like this:
You can also invoke GitHub Copilot via a shortcut (⌘+I
for macOS / Ctrl+I
for Windows/Linux) and ask questions or request modifications to your query.
Feedback: Inline GitHub Copilot suggestions
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 the GitHub Copilot's responses.
Related content
- GitHub Copilot for MSSQL extension for Visual Studio Code
- Quickstart: Generate code (Preview)
- Quickstart: Use the Schema Explorer and designer (Preview)
- Quickstart: Use the Smart Query Builder (Preview)
- Quickstart: Query Optimizer Assistant (Preview)
- Quickstart: Use the Business Logic Explainer (Preview)
- Quickstart: Security Analyzer (Preview)
- Quickstart: Localization & Formatting Helper (Preview)
- Quickstart: Generate data for testing and mocking (Preview)
- Limitations and Known Issues