mssql

Execute read-only SQL queries against multiple Microsoft SQL Server databases.

432|47|Updated Dec 22, 2025
Ready to run
npx skills add https://github.com/sanjay3290/ai-skills --skill mssql-sanjay3290
💬 Prompt for ChatGPT / Claude Chat▼
Please help me install this Agent Skill.
Skill: mssql
Source: https://github.com/sanjay3290/ai-skills/tree/main/skills/mssql
Command: npx skills add https://github.com/sanjay3290/ai-skills --skill mssql-sanjay3290

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill requires pymssql, and includes scripts (resource) components.

What problem does it solve? Querying Microsoft SQL Server databases from an AI assistant risks accidental write operations and requires juggling multiple connection credentials. This Skill enforces read-only access with query validation while managing multiple database connections through a single config file. ## Core Features & Use Cases - Read-only enforcement: Query validation blocks INSERT, UPDATE, DELETE, DROP, SELECT INTO, and multi-statement queries, allowing only SELECT, SHOW, EXPLAIN, WITH, and SP_HELP. - Multi-database management: Configure several databases in connections.json with descriptions, enabling intelligent auto-selection based on user intent. - Schema exploration: List tables and inspect column schemas via INFORMATION_SCHEMA queries, with automatic LIMIT-to-TOP conversion and a 10,000-row memory cap. - Use Case: Ask the assistant to show the top 100 recent orders from the production database; it selects the right connection, validates the query is read-only, and returns formatted results. ## Quick Start Set up connections.json with your database credentials, then ask the assistant to list the tables in your production SQL Server database.

Frequently Asked Questions about mssql

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I run read-only queries against SQL Server from Python?▼

Use pymssql to connect and execute SELECT statements, combined with client-side query validation that rejects INSERT, UPDATE, DELETE, DROP, and SELECT INTO. This Skill's query.py script handles validation, timeouts, and formatted output automatically.

How do I limit rows in MSSQL instead of using LIMIT?▼

SQL Server uses TOP N instead of LIMIT. Pass the --limit flag and the script automatically inserts TOP N after SELECT, including correct handling of SELECT DISTINCT and CTE (WITH) queries.

Can I connect to multiple SQL Server databases with one config?▼

Yes, define multiple entries in the databases array of connections.json, each with a name, description, host, and credentials. The description field helps the assistant auto-select the right database based on what you ask about.

Does pymssql support TLS encryption for Azure SQL?▼

Yes, set "encrypt": true in the connection config and the script passes encryption=require to pymssql. You can also pin a TDS protocol version such as 7.3 or 7.4 if you encounter handshake errors.

Why does my MSSQL query get rejected as not read-only?▼

Only SELECT, SHOW, EXPLAIN, WITH (followed by SELECT), and SP_HELP are permitted. Multi-statement queries containing semicolons, SELECT INTO, and CTEs ending in DELETE/UPDATE/INSERT/MERGE are blocked by design.

What are the limitations of client-side read-only enforcement?▼

pymssql has no server-side read-only session mode, so protection relies on query validation alone. For defense in depth, configure the database user with only the db_datareader role on the server.