What problem is this trying to solve?
Many security issues in applications come from the database layer: poorly written queries, dynamic SQL, or code that exposes more data than it should. These problems are often hard to spot, especially in large or older codebases.
The MSSQL extension for VS Code (v1.37+) now integrates GitHub Copilot with a dedicated chat participant: mssql.
One of its most useful capabilities is the Security Analyzer, which reviews your T-SQL code and highlights potential security weaknesses.
This is not just a generic AI model reading text. The tool connects to your SQL Server or Azure SQL database and uses the real context of your environment: your schema, tables, views, and stored procedures. That context allows it to give much more precise and relevant guidance.
Where does it work?
The Security Analyzer supports: ⢠SQL Server 2019, 2022, 2025 (Windows, Linux, containers) ⢠Azure SQL Database ⢠Azure SQL Managed Instance ⢠SQL database in Fabric
If you run a mix of on-premises, cloud, or older environments, you can still use the same tool and interface across them.
What can the Security Analyzer do?
Based on the official documentation and early testing, typical use cases include:
1ď¸âŁ Detecting SQL injection risks It reviews stored procedures and queries to find unsafe dynamic SQL, string concatenations used to build queries, or risky use of EXEC. These patterns are common entry points for SQL injection attacks.
2ď¸âŁ Identifying data overexposure It can point out views or queries that return sensitive columns (such as personal data or credentials) without masking or filtering them appropriately.
3ď¸âŁ Recommending stronger protections It suggests improvements such as encrypting connections, using Always Encrypted, applying Dynamic Data Masking, or preferring Entra ID authentication instead of storing credentials in code or configuration.
4ď¸âŁ Illustrating how an attack might work In some cases, it can generate realistic SQL injection payload examples based on your schema. This helps you understand the practical impact of a vulnerability, not just the theory.
How to try it
You will need: ⢠VS Code with the MSSQL extension (v1.37+) ⢠Your GitHub Copilot subscription ⢠A connection to a SQL Server or Azure SQL database (a dev database is recommended) Sample DB: https://github.com/Microsoft/sql-server-samples/releases/tag/wide-world-importers-v1.0
As a starting point, connect to a sample or development database (for example, AdventureWorks). Then open the Copilot chat and try prompts such as:
"@mssql Review the stored procedure SalesLT.uspGetCustomerOrderHistory for potential SQL injection vulnerabilities"
"@mssql What security best practices should I verify for the SalesLT schema?"
The tool will analyze the referenced objects and return recommendations based on the real structure of your database.
It is possible that the AIâgenerated content is incorrect. You remain responsible for reviewing, validating, and approving it before any use. Do not rely on this output without thorough human verification. Not intended for production use.
Important limitations
The Security Analyzer is helpful, but it has boundaries you should be aware of:
- Conversational, not a batch scanner: There is no built-in "scan everything" button. To review many procedures, you need to guide it or script interactions.
- Depends on context: If it is not connected to your database, it falls back to more generic suggestions that may be less useful.
- Can be wrong: Like all large language models, it can occasionally refer to objects that do not exist or misinterpret a situation when the context is incomplete. Always review its advice before making changes.
- Not a formal security audit: It is designed to help in day-to-day development and maintenance, not to serve as a compliance or certification tool.
Learn more