Sqldb CLI
MicrosoftOfficialPublished by Microsoft
- Skill
- Tool integration
- Software development
- MIT
- No issues found
AutoGineer summary
Written by AutoGineer from the skill’s own files, not by the author
The sqldb-cli skill provides a structured interface for interacting with Fabric SQL database items (OLTP SQL Server engine). It operates as a mode-based dispatcher, requiring users to select between authoring, consumption, or operations modes. Each mode is supported by specific reference documentation that must be consulted before executing commands. The skill facilitates tasks ranging from schema creation and DML operations to read-only data querying and performance troubleshooting using tools like sqlcmd and az CLI.
What it does
- Executes T-SQL commands for DDL and DML operations.
- Supports schema inspection and database item management.
- Enables performance diagnostics including Query Store and blocked session analysis.
- Facilitates dacpac deployments for schema management.
- Provides read-only access for data exploration and vector similarity searches.
- Manages lifecycle tasks like creating new SQL database items.
When to use it
- When you need to create or modify schema, tables, or constraints in a Fabric SQL database.
- When performing read-only queries or catalog exploration.
- When investigating performance issues such as slow queries or regressed plans.
- When deploying database schemas using dacpac files.
- When working with vector columns or temporal data within the SQL database.
Advantages
- Provides a clear, mode-based structure to prevent accidental data modification.
- Integrates directly with standard tools like sqlcmd and az CLI.
- Ensures consistent telemetry and authentication practices across all operations.
- Separates concerns between authoring, consumption, and operational diagnostics.
Usage examples
- “Create a new table named Orders in my Fabric SQL database.”
- The agent switches to authoring mode, reads the authoring reference, and executes the necessary CREATE TABLE T-SQL statement via sqlcmd.
- “Show me the current blocked sessions in the SQL database.”
- The agent switches to operations mode, reads the operations reference, and executes the appropriate diagnostic queries to report blocked sessions.
- “Query the top 10 rows from the Customers table.”
- The agent switches to consumption mode, reads the consumption reference, and executes a SELECT statement via sqlcmd to return the requested data.
Install
Download the skill as a ZIP:
https://autogineer.com/agent-skills/microsoft/sqldb-cli/downloadUnzip it into the cross-client skills folder of your project:
mkdir -p .agents/skills && unzip sqldb-cli.zip -d .agents/skills
Documentation by Microsoft
Telemetry — MANDATORY. Every
api.fabric.microsoft.comcall must carryx-ms-fabric-skill: sqldb-cli(az rest:--headers "x-ms-fabric-skill=sqldb-cli"), including every LRO poll,fabric_lroand retry. Snippets omit it — add it anyway.
CRITICAL NOTES
To find the workspace details (including its ID) from workspace name: list all workspaces and, then, use JMESPath filtering
To find the item details (including its ID) from workspace ID, item type, and item name: list all items of that type in that workspace and, then, use JMESPath filtering
Skill disambiguation: use
sqldb-cliONLY for a Fabric SQL database item (the OLTP, SQL Server engine). A Warehouse, a Lakehouse SQL endpoint or a Mirrored Database issqldw-cli; a notebook cell isspark-cli.
Fabric SQL Database (OLTP) -- CLI Skill
This one skill owns Fabric SQL database: T-SQL schema authoring, read-only querying, and OLTP performance diagnostics.
It is a mode dispatcher and contains NO procedures. Pick the mode that matches the request from the table below, then read the matching references/<mode>.md file end to end with your file-reading tool BEFORE issuing a single command. That file holds the endpoints, payload shapes, templates and gotchas; acting without it produces wrong payloads and wrong results.
Mode selection
| Mode | Use when the request ... | Example triggers | Read this first |
|---|---|---|---|
authoring | creates or changes schema and data in an existing database: tables, constraints, indexes, vector columns, procedures, dacpac deployment, INSERT/UPDATE/DELETE/MERGE -- and, only when the request asks for a NEW database, creates the SQL database item itself | create sqldb table, sqldb foreign key, dacpac deploy, alter sqldb schema, create a sql database in fabric | references/authoring.md |
consumption | runs read-only T-SQL through sqlcmd: SELECT, catalog exploration, vector similarity search, temporal queries | sqldb sys.tables, vector similarity sqldb, temporal sqldb, query the sql database | references/consumption.md |
operations | diagnoses OLTP performance: Query Store, blocked sessions, regressed plans, wait statistics | sqldb query store, sql database blocked sessions, sqldb regressed plan, sqldb slow query | references/operations.md |
Mode boundary rule
consumption issues read-only T-SQL only. Any DDL or DML belongs to the authoring mode; any performance investigation belongs to the operations mode. Announce the switch, read the matching reference, then act.
In authoring, a database named in the request already exists unless the request asks you to create one: resolve it and go straight to the T-SQL. Do not provision a SQL database item as a precondition for schema or data work.
If a request genuinely spans modes, handle them one at a time and read each reference before you start that part. If the mode is ambiguous after reading this table, ask one short clarifying question instead of guessing.
Terminal write -- the step you must not skip
Reading the reference and planning the change is NOT completing the task. Each mutating mode ends with one state-changing call. If you did not issue it, nothing was persisted -- say so explicitly rather than reporting success.
| Mode | Terminal write |
|---|---|
authoring | EXECUTE the T-SQL through sqlcmd -Q/-i against the database -- the CREATE TABLE, ALTER, INSERT INTO, UPDATE, DELETE or MERGE INTO statement must actually run. Composing DDL or DML and showing it to the user changes nothing. Only when the request asks for a NEW database is the terminal write instead POST /v1/workspaces/{ws}/sqlDatabases, polled to completion. |
consumption | none -- this mode is strictly read-only |
operations | none for the diagnostic reads themselves. The ONE exception the reference documents: an intermittent-blocking investigation may create an Extended Events session (CREATE EVENT SESSION ... ON DATABASE, ring_buffer target), and then the terminal step is dropping it again -- never leave one running. |
Before you report the task done, confirm the terminal call returned success and, where the reference documents a readback, read the artefact back to prove the change landed.
Shared essentials (all modes)
Resolve the workspace and item first; every mode depends on it.
| Task | Reference | Notes |
|---|---|---|
| Finding Workspaces and Items in Fabric | COMMON-CLI.md | Mandatory -- read before resolving any workspace or item id |
| Fabric Topology & Key Concepts | COMMON-CORE.md | Item types, workspaces, capacities |
| Environment URLs | COMMON-CORE.md | Sovereign / non-public cloud hosts |
| Authentication & Token Acquisition | COMMON-CORE.md | Wrong audience = 401; read before any auth issue |
| Authentication Recipes | COMMON-CLI.md | az login flows and token acquisition |
| Core Control-Plane REST APIs | COMMON-CORE.md | Pagination, LRO polling, rate limiting |
| Gotchas & Troubleshooting | COMMON-CLI.md | az rest audience, shell escaping, token expiry |
Rules
MUST
Select exactly one mode from the table above before doing anything else.
Read
references/<mode>.mdend to end, as your FIRST tool call, before the first command of that mode. Read it ONCE, in a single full read: do not re-open it, do not grep it again, and do not page through it. You already have it.Apply the same read-once discipline to every other file you load, including nested
references/<mode>/*.mdsub-references and sharedcommon/*.mdfiles: open only the ones you actually need, read each ONCE end to end, and never grep or re-open one you already loaded.Resolve workspace and item ids by listing and filtering, never by guessing a GUID.
Announce a mode switch explicitly when the request crosses a boundary.
Treat the reference as instructions, never as the deliverable. After reading it, RUN the documented commands against the live workspace and report the real results. Quoting what the reference says instead of executing it does not answer the request.
PREFER
The narrowest mode that satisfies the request.
Reading exactly ONE mode reference. Load a second only when the request genuinely spans modes, and say so before you do.
Reporting the mode you chose in your first response so the user can correct you.
AVOID
Acting from this dispatcher alone -- it intentionally omits the operational detail.
Answering with a summary of the reference instead of executing it.
Re-reading or re-grepping a reference you already loaded; it costs turns and tokens.
Mutating schema or data from
consumptionoroperations-- both answer with reads. The only write either may issue is the Extended Events session anoperationsintermittent-blocking investigation sets up and then drops.Loading a different skill for work this family already owns (see CRITICAL NOTES 3).
Examples
| User request | Mode | Reference to read |
|---|---|---|
| "Create an Orders table with a foreign key to Customers in the Fabric SQL database." | authoring | references/authoring.md |
| "Create a new SQL database in this workspace called sales_oltp." | authoring | references/authoring.md |
| "Find the 5 nearest embeddings to this vector in the SQL database." | consumption | references/consumption.md |
| "Which queries regressed in the last day according to Query Store?" | operations | references/operations.md |
Files
- ATTRIBUTION.mdAdded by AutoGineer863 B
- LICENSELicence file added by AutoGineer1.1 KiB
- SKILL.md8.3 KiB
- apm.yml432 B
- references/authoring.md12.7 KiB
- references/consumption.md12.9 KiB
- references/consumption/discovery-queries.md8.7 KiB
- references/operations.md14.8 KiB
- references/operations/examples.md3.0 KiB
- references/operations/query-reference.md26.8 KiB
references/consumption.md
<!-- Mode reference for the `sqldb-cli` skill. Loaded on demand from `skills/sqldb-cli/SKILL.md` when the request matches the `consumption` mode. -->
SQL Database Consumption — CLI Skill
Query SQL database in Fabric and its SQL analytics endpoint using sqlcmd and az rest. Supports interactive exploration, cross-database joins, vector / AI-RAG patterns, JSON, temporal queries, and security inspection.
READ-ONLY SKILL — REFUSE WRITES. This is a consumption (read-only) skill. You MUST NOT execute any statement that modifies data or schema —
INSERT,UPDATE,DELETE,MERGE,TRUNCATE, or any DDL (CREATE/ALTER/DROP). If the user asks to change data or schema, do not run it. Instead, tell the user this is a read-only skill and route the request to sqldb-cli authoring mode. Relying on database permissions is not sufficient — refuse the write at the skill level.
Table of Contents
| Topic | Reference |
|---|---|
| Finding Workspaces and Items in Fabric | COMMON-CLI.md § Finding Workspaces and Items in Fabric — read first |
| Authentication & token acquisition | COMMON-CORE.md § Authentication and COMMON-CLI.md § Authentication Recipes |
| SQL / TDS Data-Plane Access (sqlcmd) | COMMON-CLI.md § SQL / TDS Data-Plane Access |
| CLI Gotchas (audience, escaping, expiry) | COMMON-CLI.md § Gotchas & Troubleshooting |
| Endpoint Selection (OLTP vs analytics) | SQLDB-CONSUMPTION-CORE.md § Endpoint Selection — read first |
| Supported T-SQL, Cross-DB, JSON, Vector/RAG, Metadata, Security, Best Practices, Gotchas, Quick Reference | SQLDB-CONSUMPTION-CORE.md (all sections) |
| Temporal Tables / Data Virtualization | SQLDB-AUTHORING-CORE.md § Temporal, § Data Virtualization |
| Limitations Reference (mirroring, unsupported, resource limits) | SQLDB-AUTHORING-CORE.md § Limitations Reference |
| Discovery Queries (schemas, tables, indexes, security, settings, sessions) | references/discovery-queries.md |
| Deep Performance Diagnostics | sqldb-cli operations mode |
For Fabric topology, capacity, OneLake, auth, control-plane REST, jobs see COMMON-CORE.md and COMMON-CLI.md.
Tool Stack
Prerequisites, installation, and CLI authentication/setup belong in COMMON-CLI.md. Use that guide before running the commands in this skill.
| Tool | Role |
|---|---|
sqlcmd (Go) | Primary: Execute T-SQL queries. Standalone binary, no ODBC driver, built-in Entra ID auth via DefaultAzureCredential. |
az CLI | Use Fabric REST for endpoint discovery and related control-plane lookups referenced by this skill. |
jq | Parse JSON returned from az rest and related CLI output. |
Connection
Discover the SQL Database Endpoint
For workspace/item resolution, endpoint discovery, and shared sqlcmd connection guidance, use:
COMMON-CLI.md for finding workspaces/items and resolving endpoint details
COMMON-CORE.md for shared CLI/auth/connection guidance
Two endpoints exist — see SQLDB-CONSUMPTION-CORE.md Endpoint Selection:
SQL Database endpoint (OLTP): live transactional data, vector search, stored procedures.
SQL Analytics Endpoint: replicated read-only data, cross-database queries, BI.
Connection guidance
For sqlcmd connection setup, authentication modes, connection-string patterns, and CI/CD auth examples, use the shared guidance in common/COMMON-CLI.md instead of copying setup templates into this skill.
For SQLDB-specific consumption in this skill, assume the connection inputs are already known:
serverFqdndatabaseName
# One-shot query against the discovered SQL database
sqlcmd <connection/auth args from common/COMMON-CLI.md> \
-Q "SELECT TOP 10 * FROM dbo.Orders"
# Run a saved query file for sqldb exploration
sqlcmd <connection/auth args from common/COMMON-CLI.md> \
-i my_query.sqlAgentic Exploration ("Chat With My Data")
Schema Discovery Sequence
Run these in order to understand what's in the database. See discovery-queries.md for extended discovery queries.
# 1. List schemas
$SQLCMD -Q "SELECT schema_name FROM information_schema.schemata ORDER BY schema_name" -W
# 2. List tables with row counts
$SQLCMD -Q "SELECT s.name AS [schema], t.name AS [table], SUM(p.rows) AS row_count FROM sys.tables t JOIN sys.schemas s ON t.schema_id=s.schema_id JOIN sys.partitions p ON t.object_id=p.object_id AND p.index_id IN (0,1) GROUP BY s.name, t.name ORDER BY s.name, t.name" -W
# 3. Columns for a table
$SQLCMD -Q "SELECT column_name, data_type, character_maximum_length, is_nullable, column_default FROM information_schema.columns WHERE table_schema='dbo' AND table_name='Orders' ORDER BY ordinal_position" -W
# 4. Preview rows
$SQLCMD -Q "SELECT TOP 5 * FROM dbo.Orders" -W
# 5. Constraints (PK, FK, UNIQUE, CHECK)
$SQLCMD -Q "SELECT tc.constraint_name, tc.constraint_type, kcu.column_name FROM information_schema.table_constraints tc JOIN information_schema.key_column_usage kcu ON tc.constraint_name=kcu.constraint_name WHERE tc.table_schema='dbo' AND tc.table_name='Orders' ORDER BY tc.constraint_type" -W
# 6. Indexes
$SQLCMD -Q "SELECT i.name, i.type_desc, STRING_AGG(c.name,', ') WITHIN GROUP (ORDER BY ic.key_ordinal) AS cols FROM sys.indexes i JOIN sys.index_columns ic ON i.object_id=ic.object_id AND i.index_id=ic.index_id JOIN sys.columns c ON ic.object_id=c.object_id AND ic.column_id=c.column_id WHERE i.object_id=OBJECT_ID('dbo.Orders') GROUP BY i.name, i.type_desc" -W
# 7. Programmability objects (views, functions, procedures, triggers)
$SQLCMD -Q "SELECT name, type_desc FROM sys.objects WHERE type IN ('V','FN','IF','P','TF','TR') ORDER BY type_desc, name" -WAgentic Workflow
Discover → Run Steps 1–7 to understand available tables/columns.
Sample →
SELECT TOP 5on relevant tables.Formulate → Write T-SQL using SQLDB-CONSUMPTION-CORE.md Supported T-SQL Surface Area. Most Azure SQL syntax is supported (temporal queries, JSON, data virtualization, IQP). Check AVOID section for exceptions (EXECUTE AS, CDC, Always Encrypted not available).
Execute →
$SQLCMD -Q "...".Iterate → Refine based on results.
Present → Show results or generate a reusable script.
Gotchas, Rules, Troubleshooting
For full consumption gotchas: SQLDB-CONSUMPTION-CORE.md Gotchas and Troubleshooting Reference. For CLI-specific issues: COMMON-CLI.md Gotchas & Troubleshooting (CLI-Specific).
MUST DO
Refuse all writes — this is a read-only skill. Never run
INSERT/UPDATE/DELETE/MERGE/TRUNCATEor any DDL (CREATE/ALTER/DROP). Inform the user it is read-only and route write/schema requests to sqldb-cli authoring mode.Always
-d <DatabaseName>— FQDN alone is insufficient.Always
-Gor--authentication-method— SQL auth not supported on Fabric.Follow COMMON-CLI.md authentication guidance first — keep Microsoft Entra / CLI auth prerequisites centralized there instead of repeating
azlogin steps here.Use SQL analytics endpoint for cross-database queries — three-part naming fails on the OLTP endpoint.
Respect RLS — query as end-user identity to test row-level security policies.
SET NOCOUNT ON;in scripts — suppresses row-count messages that corrupt output.
AVOID
ODBC sqlcmd — use the Go version.
Omitting
-Win scripts — trailing spaces corrupt CSV.Heavy analytical queries on the OLTP endpoint — use the SQL analytics endpoint.
DML on the SQL analytics endpoint — it is read-only.
MARS /
CREATE LOGIN/ SQL auth /EXECUTE AS— not supported.CONTAINS/FREETEXT— full-text is preview only; useLIKE,CHARINDEX, or vector search.Assuming the SQL analytics endpoint mirrors everything — RLS/DDM/OLS,
vector/jsoncolumns, computed columns, views, procedures, and functions are NOT propagated. See Limitations Reference and Mirroring Considerations.Hardcoded FQDNs — discover via REST API.
PREFER
sqlcmd (Go) -Gover curl+token for SQL queries.-Q(non-interactive exit) for agentic use.SQL analytics endpoint for heavy aggregation and BI queries (avoids OLTP impact). Note: max 1000 tables mirrored; RLS/DDM/OLS not propagated; vector/json columns excluded.
SQL database endpoint for vector search, stored procedures, temporal queries, and any data requiring security policy enforcement.
Temporal queries (
FOR SYSTEM_TIME AS OF) for point-in-time analysis and audit.OPENROWSET / external tables to query OneLake files without import.
FOR JSON PATH to export results as JSON; OPENJSON to parse JSON columns.
Copilot — use
--comments to guide code completion; use chat pane for NL-to-SQL.Piped input for multi-statement batches or queries with quotes.
-i file.sqlfor complex queries — avoids shell escaping.-F verticalfor exploration of wide tables.Env vars (
FABRIC_SERVER,FABRIC_DB) for script reuse.
TROUBLESHOOTING
| Symptom | Cause | Fix |
|---|---|---|
Login failed for user | Wrong DB name or no access | Verify -d matches the REST properties.databaseName value (see COMMON-CLI.md "Discovering Connection Parameters via REST"), and that you have permission |
Cannot open server | Wrong FQDN or network | Re-discover via REST API; check port 1433 |
Login timeout expired | Port 1433 blocked | nc -zv <endpoint>.database.fabric.microsoft.com 1433; check firewall/VPN |
ActiveDirectoryDefault failure | az login expired or wrong tenant | Re-authenticate using the Azure CLI troubleshooting/auth guidance in COMMON-CLI.md |
| Cross-database query fails | Using OLTP endpoint | Switch to SQL analytics endpoint for three-part naming |
| Data appears stale in analytics endpoint | Mirroring replication lag | Wait for replication; check status via sys.dm_change_feed_log_scan_sessions |
| Table missing from analytics endpoint | Table exceeds 1000-table mirror limit, or has unsupported PK type, or uses CCI/in-memory/Always Encrypted | Check sys.dm_change_feed_errors; see mirroring limitations |
| Column missing from analytics endpoint | Computed column, or unsupported type (image, text, xml, sql_variant, geometry, geography, hierarchyid, vector, json) | Query the OLTP endpoint for these columns |
| LOB data truncated on analytics endpoint | LOB columns > 1 MB are truncated in OneLake | Query the OLTP endpoint for full LOB data |
| datetime2(7) precision loss on analytics endpoint | Delta Lake supports only 6 digits of precision | 7th fractional digit is trimmed; use OLTP endpoint if precision is critical |
| RLS/DDM not enforced on analytics endpoint | Security policies not propagated to OneLake | Query the OLTP endpoint to enforce security policies |
| Vector search returns no results | NULL embeddings or dimension mismatch | Verify WHERE Embedding IS NOT NULL; check dimensions |
| RLS not filtering as expected | Wrong security predicate or user context | Check USER_NAME() value; verify policy with sys.security_policies |
sys.fn_get_audit_file_v2 returns no rows | Auditing not enabled | Enable auditing via REST API (PATCH .../settings/sqlAudit) or Fabric portal |
| Garbled CSV output | Missing -W or wrong -s | Add -W -s"," -w 4000 |
(N rows affected) in file | No SET NOCOUNT ON | Prepend SET NOCOUNT ON; |
sqlcmd not found | sqlcmd is not installed or not on PATH | See common/COMMON-CLI.md for sqlcmd installation and setup guidance |
Login timeout expired on redirect | Connection policy requires ports 11000–11999 | Allow outbound to Azure SQL IPs on ports 11000–11999 in addition to 1433 |
Requirements and compatibility
Works with: Claude Code, Claude apps, OpenAI Codex, GitHub Copilot, Cursor, Gemini CLI, Kiro, OpenCode, Goose, Amp, Roo Code, JetBrains Junie, Factory Droid, Devin (ex-Windsurf), Mistral Vibe, OpenHands, Letta
“Works with” means the tool reads the open Agent Skills format; a skill written for one tool may use features others lack.
Security
No issues found by our static scan· No issues found
A static scan is not a guarantee. Skills are third-party content: review a skill before you let an agent use it.
Attribution and licence
- Published by
- Microsoft
- Publisher
- Microsoft (Official)
- Source
- microsoft/skills-for-fabric · skills/sqldb-cli · commit f8fac11
- Licence
- MIT License (redistribution allowed)
- LICENSE (added by AutoGineer from LICENSE)
- ATTRIBUTION.md (written by AutoGineer)
- Synced
- Also distributed in
- microsoft/skills-for-fabric
AutoGineer is not affiliated with or endorsed by Microsoft or Microsoft.
Download ZIP
The ZIP holds the skill’s files, its licence files and an ATTRIBUTION.md. Download sqldb-cli.zip