Edit

Share via


GitHub Copilot for MSSQL extension for Visual Studio Code

The GitHub Copilot integration with the MSSQL extension for Visual Studio Code introduces AI-assisted development directly within the SQL development workflow.

This new feature empowers developers to write and optimize database code, generate and evolve schemas, understand existing logic, and work more confidently with code-first and data-first database development patterns using GitHub Copilot's intelligent, context-aware suggestions.

This integration is designed for developers, with a focus on the following key personas:

  • Modern application developer: Build feature-rich, scalable applications with frameworks like Node.js, Python, .NET, and Go.

  • AI / cloud-native developer: Specialize in containerized, serverless, and microservices-based applications, often integrating AI-powered capabilities.

  • Solutions architect: Design end-to-end systems that align database solutions with broader architectural goals.

  • Database developer: Focus on T-SQL, database-specific concepts, and optimizing database workflows.

What is the MSSQL extension for Visual Studio Code?

The MSSQL extension in Visual Studio Code is designed to help developers seamlessly work with their databases, simplifying the use of SQL database in Fabric, all Azure SQL offerings, and SQL Server as the backend for their applications.

To learn more about the extension, visit the GitHub repository.

What is GitHub Copilot for the MSSQL extension for Visual Studio Code?

GitHub Copilot for the MSSQL extension integrates the power of AI-driven assistance directly into your SQL development workflow within Visual Studio Code. It enables developers to:

  • Explore, design, and evolve database schemas using intelligent, code-first / data-first guidance.
  • Apply contextual suggestions for SQL syntax, relationships, and constraints.
  • Write, optimize, and troubleshoot SQL queries with AI-recommended improvements.
  • Generate mock data and seed scripts to support testing and development environments.
  • Accelerate schema evolution by autogenerating ORM (Object-Relational Mapping) migrations or T-SQL change scripts.
  • Understand and document business logic embedded in stored procedures, views, and functions.
  • Get security-related recommendations, such as avoiding SQL injection or excessive permissions.
  • Receive natural language explanations to help developers unfamiliar with T-SQL write and understand code confidently.
  • Help reverse-engineering existing databases by explaining SQL schemas and relationships.
  • Help scaffold backend components (for example, data access layers) based on your current database context.

Supported SQL Server platforms

GitHub Copilot for the MSSQL extension works with all of these SQL Server platforms:

SQL Server

  • SQL Server 2019 (15.x)
  • SQL Server 2022 (16.x)
  • SQL Server 2025 (17.x)
  • SQL Server running on any platform:
    • Windows
    • Linux
    • Containers (local and Kubernetes deployments)

Azure SQL

  • Azure SQL Database
  • Azure SQL Managed Instance
  • SQL Server on Azure Virtual Machines

Microsoft Fabric

  • SQL database in Fabric
  • Fabric Data Warehouse
  • Fabric Lakehouse (SQL analytics endpoint)

Target audience

GitHub Copilot for the MSSQL extension is designed for developers who work with applications and SQL databases in Visual Studio Code. It provides intelligent assistance to help you write, optimize, and understand database code more effectively.

Persona Description
Modern application developer Build robust, scalable applications using frameworks like React, Angular, .NET, Django, and Node.js, often following a code-first approach where application logic drives database design. GitHub Copilot streamlines database interactions by assisting with schema generation, query authoring, and integration patterns directly from your codebase, boosting productivity and minimizing context switching.
AI / cloud-native developer Build serverless, containerized, and microservices-based solutions that integrate AI capabilities, both within the application and the database layer. GitHub Copilot accelerates development by generating intelligent T-SQL queries, managing schema changes, and assisting with data access patterns common in cloud-native architectures. It also helps developers use AI features built into the database, such as vector search and hybrid retrieval scenarios, to build intelligent, AI-ready applications.
Solutions architect Design data-centric systems and ensuring consistency across services and environments. GitHub Copilot helps visualize, validate, and prototype database interactions, making it easier to align database design with system architecture goals.
Database engineer Manage schema evolution, writing complex T-SQL queries, and optimizing performance. GitHub Copilot speeds up development by offering suggestions, explaining code, and identifying potential optimizations, boosting both speed and confidence.

Features

Feature Description
Chat / inline Copilot suggestions Engage in natural language conversations with the @mssql chat participant or use inline completions for T-SQL or ORM code. Suggestions adapt based on your database schema and active files.
Schema explorer and designer Understand, design, and evolve your database schema using AI assistance. Supports object creation, relationships, and reverse engineering.
Smart query builder Generate SQL and ORM (Object-Relational Mapping) queries using filters, joins, groupings, and conditions, based on schema awareness and natural language prompts.
Code generation Quickly scaffold database code, stored procedures, or ORM-based data access layers based on your current database schema and active files. GitHub Copilot understands your context and can generate repeatable patterns such as CRUD operations or access methods aligned with your development stack.
Query optimizer assistant Get AI-generated tips for improving the performance of your SQL queries. GitHub Copilot might suggest better indexing strategies, refactor joins, or spot inefficiencies in WHERE clauses, helpful for developers who aren't experts in performance tuning. Additionally, it supports analysis of execution plans for in-depth analysis, enabling more precise recommendations tailored to your query's actual execution context.
Business logic explainer Ask GitHub Copilot to explain in simple terms what a stored procedure, view, or user-defined function does. This is especially useful for onboarding new developers who need to understand how business rules are implemented without reading hundreds of lines of T-SQL code.
Security analyzer GitHub Copilot can analyze patterns that might expose your code to SQL injection, overly permissive roles, or unencrypted sensitive data. It can also recommend safer ways to handle credentials, user input, and authentication flows, directly in your context.
Localization and formatting helper Whether you're building multilingual apps or just ensuring proper sorting and encoding, GitHub Copilot can suggest appropriate collation settings, Unicode usage, and query patterns that support language-specific and region-specific requirements.
Test data generator Generate close to realistic, schema-aware sample data (via SQL INSERTs or ORM seeders) to populate your development environment. GitHub Copilot can even extrapolate schema from an existing sample (JSON, CSV, TXT) or autogenerate themed data to support prototyping or testing.

Prerequisites

Install Visual Studio Code

  1. Download Visual Studio Code here.
  2. Complete the installation following the wizard.

Install the MSSQL extension in Visual Studio Code

To get started with SQL development in Visual Studio Code, install the MSSQL extension:

  1. Open Visual Studio Code.

  2. Select the Extensions icon in the Activity Bar (press Cmd+Shift+X on macOS or Ctrl+Shift+X on Windows/Linux).

  3. In the search bar, type mssql.

  4. Find SQL Server (mssql) in the results and select it.

  5. Select the Install button.

    Screenshot of the MSSQL extension in Visual Studio Code.

Tip

If you're unfamiliar with the MSSQL extension for Visual Studio Code, get a comprehensive overview of its features and capabilities in What is the MSSQL extension for Visual Studio Code?

Set up GitHub Copilot in Visual Studio Code

  1. Make sure you have a GitHub account. If you don't have one, sign up for free at GitHub.

  2. Ensure you have an active GitHub Copilot subscription. You can start a free trial or purchase a subscription at GitHub Copilot.

  3. In Visual Studio Code, open the Extensions view (press Cmd+Shift+X on macOS or Ctrl+Shift+X on Windows/Linux).

  4. Search for and install both GitHub Copilot and GitHub Copilot Chat extensions.

    Screenshot of the GitHub Copilot extension in Visual Studio Code.

  5. After installation, you'll need to sign in to your GitHub account. Use Visual Studio Code command palette GitHub Copilot: Sign in or sign in using the GitHub Copilot icon from the status bar at the bottom of the window.

    Screenshot of the GitHub Copilot sign-in in Visual Studio Code.

  6. After signing in, you might need to authorize the GitHub Copilot extension to access your GitHub account. Follow the prompts to complete the authorization process.

  7. Once you're signed in, GitHub Copilot is active and ready to assist as you write code in your editor.

For more information, see the official Quickstart for GitHub Copilot in Visual Studio Code.

Connect to a database

To get started with GitHub Copilot for the MSSQL extension, connect to a supported SQL Server or Azure SQL database from the Connections view in Visual Studio Code.

Note

For step-by-step instructions on how to create a new connection profile and connect to a database, see Quickstart: Connect to and query a database with the MSSQL extension for Visual Studio Code.

Start chatting with your database

You can begin using GitHub Copilot by initiating a chat session with your database:

  1. Go to the Connections view in the MSSQL extension.

  2. Right-click on a connected database.

  3. Select Chat with this database from the context menu.

    Screenshot showing the database context menu, selecting the Chat with this database option.

After selecting this option, you'll be prompted to allow the MSSQL extension to access the language models provided by GitHub Copilot Chat.
This is required to enable contextual conversations about your database.

Screenshot of Placeholder for Copilot access notification.

Once approved, a GitHub Copilot chat window opens in the context of the selected database. You're now ready for starting asking questions, generating SQL, or exploring schema insights using natural language.

Manage database context

GitHub Copilot uses your current database connection to provide schema-aware suggestions. The @mssql chat participant automatically detects your connection status and adapts its behavior accordingly.

Connect to a database

When you start an Ask mode session with @mssql without an active database connection, the chat participant detects this and provides helpful guidance to establish a connection:

Screenshot showing the @mssql chat participant detecting no database connection and prompting the user to connect.

You can connect to a database in multiple ways:

  1. Use the GitHub Copilot's chat interface: When prompted by the @mssql participant, select the Open SQL editor and connect button to launch the connection dialog.

  2. Use the MSSQL extension: Use the Connect command from the MSSQL extension's Connections view to create or select a connection profile.

  3. Use slash commands: Type @mssql /connect in the GitHub Copilot chat to quickly open the connection dialog. For more connection-related slash commands, see Connection management slash commands.

  4. Use Agent Mode: If you're using Quickstart: Use GitHub Copilot Agent Mode, you can connect directly through natural language prompts without requiring a pre-established connection. For more information on how Agent Mode handles connections, see How connection logic works.

Animation showing the complete flow of connecting to a database through the @mssql chat participant.

Welcome message and database context

Once connected, the @mssql chat participant greets you with a personalized welcome message showing your current connection details:

Screenshot of the @mssql chat participant welcome message showing the connected database details.

The welcome message displays:

  • Your connected server
  • Your current database name
  • Available capabilities and assistance options

Switch database contexts

If you want to switch to a different database while working, you have several options:

  • Use the Change Database button: Use the Change Database button in the MSSQL extension sidebar

    Screenshot of the GitHub Copilot chat window and MSSQL extension changing database context using the change database option in Visual Studio Code.

  • Use the status bar: Select the status bar panel displaying the current connection (server, database, user). This opens a dropdown list to select a different database from your configured profiles.

    Screenshot of the GitHub Copilot chat window and MSSQL extension changing database context using the status bar in Visual Studio Code.

    Important

    GitHub Copilot requires an active database connection to provide meaningful, schema-aware suggestions. Without a connection, the @mssql participant guides you to establish one before proceeding with database-related tasks.

  • Use slash commands: Type @mssql /changeDatabase in the GitHub Copilot chat to quickly switch to a different database. For more information, see Connection management slash commands.

  • Use Agent Mode tools: Use natural language prompts with Agent Mode to switch databases. For more information, see Connection management in Agent Mode.

    Note

    When using GitHub Copilot Agent Mode, you can connect to databases without requiring a pre-established connection. Agent Mode uses tools contributed by the MSSQL extension to handle connections through natural language prompts or chat variables like #mssql_connect. For details, see How connection logic works.

This intelligent connection detection gives you a seamless experience, whether you're connecting for the first time or switching between environments while retaining context-aware assistance from GitHub Copilot.

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 the GitHub Copilot's responses.