Connect to a Microsoft SQL Server database to inspect its schema (tables, columns, indexes, foreign keys, views) and execute read-only SQL queries. Use when the user needs to explore or retrieve data from a SQL Server database.
Inspect schemas and run read-only queries against a Microsoft SQL Server database using the bundled helper script.
Before first use, ensure the pyodbc Python package is installed:
pip install pyodbc
You also need an ODBC driver for SQL Server installed on the system. The script auto-detects installed drivers. Common drivers:
brew install microsoft/mssql-release/msodbcsql18${CLAUDE_SKILL_DIR}/scripts/query_sqlserver.py
| Argument | Env Variable | Default | Description |
|---|---|---|---|
--host | MSSQL_HOST | localhost | Database host |
--port | MSSQL_PORT | 1433 | Database port |
--database | MSSQL_DATABASE | master | Database name |
--user | MSSQL_USER | (none) | Username |
--password | MSSQL_PASSWORD | (none) | Password |
--driver | MSSQL_DRIVER | (auto) | ODBC driver name |
--connection-string | MSSQL_CONNSTR | (none) | Full ODBC connection string |
--trusted | (flag) | false | Use Windows/Kerberos trusted auth |
Ask the user for connection details before running the script. Never guess or assume credentials.
List all tables and views:
python3 ${CLAUDE_SKILL_DIR}/scripts/query_sqlserver.py --host <host> --database <db> --user <user> --password <pass> schema
Inspect a specific table:
python3 ${CLAUDE_SKILL_DIR}/scripts/query_sqlserver.py --host <host> --database <db> --user <user> --password <pass> schema --table <table_name>
Filter by schema:
python3 ${CLAUDE_SKILL_DIR}/scripts/query_sqlserver.py --host <host> --database <db> --user <user> --password <pass> schema --schema dbo
List all databases on the server:
python3 ${CLAUDE_SKILL_DIR}/scripts/query_sqlserver.py --host <host> --user <user> --password <pass> schema --list-databases
Run a read-only SQL query:
python3 ${CLAUDE_SKILL_DIR}/scripts/query_sqlserver.py --host <host> --database <db> --user <user> --password <pass> query "SELECT TOP 10 * FROM users"
Output as JSON:
python3 ${CLAUDE_SKILL_DIR}/scripts/query_sqlserver.py --host <host> --database <db> --user <user> --password <pass> query --format json "SELECT TOP 10 * FROM users"
SET TRANSACTION ISOLATION LEVEL READ UNCOMMITTED on every connection.ApplicationIntent=ReadOnly where supported.--limit <N> to change this.--limit to avoid returning excessively large result sets.TOP N in SQL Server queries instead of LIMIT N (SQL Server syntax).