Generated banner for Sqldb CLI
Generated logo for Sqldb CLI

Sqldb CLI

MicrosoftOfficialPublished by Microsoft

  • Skill
  • Tool integration
  • Software development
  • MIT
  • No issues found

From the author

Manages a Fabric SQL database item, the OLTP SQL Server engine, including running T-SQL through sqlcmd, temporal and vector similarity search, schema and sys.tables inspection, dacpac deployment, and Query Store, blocked sessions and regressed-plan investigation. Use for any query or change against a SQL database item. Warehouse, lakehouse SQL endpoint and mirrored items belong to sqldw-cli.
— the description by Microsoft

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

  1. Download the skill as a ZIP:

    https://mp-staging.autogineer.com/agent-skills/microsoft/sqldb-cli/download
  2. Unzip 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.com call must carry x-ms-fabric-skill: sqldb-cli (az rest: --headers "x-ms-fabric-skill=sqldb-cli"), including every LRO poll, fabric_lro and retry. Snippets omit it — add it anyway.

CRITICAL NOTES

  1. To find the workspace details (including its ID) from workspace name: list all workspaces and, then, use JMESPath filtering

  2. 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

  3. Skill disambiguation: use sqldb-cli ONLY for a Fabric SQL database item (the OLTP, SQL Server engine). A Warehouse, a Lakehouse SQL endpoint or a Mirrored Database is sqldw-cli; a notebook cell is spark-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

ModeUse when the request ...Example triggersRead this first
authoringcreates 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 itselfcreate sqldb table, sqldb foreign key, dacpac deploy, alter sqldb schema, create a sql database in fabricreferences/authoring.md
consumptionruns read-only T-SQL through sqlcmd: SELECT, catalog exploration, vector similarity search, temporal queriessqldb sys.tables, vector similarity sqldb, temporal sqldb, query the sql databasereferences/consumption.md
operationsdiagnoses OLTP performance: Query Store, blocked sessions, regressed plans, wait statisticssqldb query store, sql database blocked sessions, sqldb regressed plan, sqldb slow queryreferences/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.

ModeTerminal write
authoringEXECUTE 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.
consumptionnone -- this mode is strictly read-only
operationsnone 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.

TaskReferenceNotes
Finding Workspaces and Items in FabricCOMMON-CLI.mdMandatory -- read before resolving any workspace or item id
Fabric Topology & Key ConceptsCOMMON-CORE.mdItem types, workspaces, capacities
Environment URLsCOMMON-CORE.mdSovereign / non-public cloud hosts
Authentication & Token AcquisitionCOMMON-CORE.mdWrong audience = 401; read before any auth issue
Authentication RecipesCOMMON-CLI.mdaz login flows and token acquisition
Core Control-Plane REST APIsCOMMON-CORE.mdPagination, LRO polling, rate limiting
Gotchas & TroubleshootingCOMMON-CLI.mdaz rest audience, shell escaping, token expiry

Rules

MUST
  • Select exactly one mode from the table above before doing anything else.

  • Read references/<mode>.md end 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>/*.md sub-references and shared common/*.md files: 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 consumption or operations -- both answer with reads. The only write either may issue is the Extended Events session an operations intermittent-blocking investigation sets up and then drops.

  • Loading a different skill for work this family already owns (see CRITICAL NOTES 3).

Examples

User requestModeReference to read
"Create an Orders table with a foreign key to Customers in the Fabric SQL database."authoringreferences/authoring.md
"Create a new SQL database in this workspace called sales_oltp."authoringreferences/authoring.md
"Find the 5 nearest embeddings to this vector in the SQL database."consumptionreferences/consumption.md
"Which queries regressed in the last day according to Query Store?"operationsreferences/operations.md

Files

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

TopicReference
Finding Workspaces and Items in FabricCOMMON-CLI.md § Finding Workspaces and Items in Fabric — read first
Authentication & token acquisitionCOMMON-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 ReferenceSQLDB-CONSUMPTION-CORE.md (all sections)
Temporal Tables / Data VirtualizationSQLDB-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 Diagnosticssqldb-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.

ToolRole
sqlcmd (Go)Primary: Execute T-SQL queries. Standalone binary, no ODBC driver, built-in Entra ID auth via DefaultAzureCredential.
az CLIUse Fabric REST for endpoint discovery and related control-plane lookups referenced by this skill.
jqParse 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:

  • serverFqdn

  • databaseName

# 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.sql

Agentic 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" -W
Agentic Workflow
  1. Discover → Run Steps 1–7 to understand available tables/columns.

  2. Sample → SELECT TOP 5 on relevant tables.

  3. 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).

  4. Execute → $SQLCMD -Q "...".

  5. Iterate → Refine based on results.

  6. 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 / TRUNCATE or 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 -G or --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 az login 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 -W in 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; use LIKE, CHARINDEX, or vector search.

  • Assuming the SQL analytics endpoint mirrors everything — RLS/DDM/OLS, vector/json columns, computed columns, views, procedures, and functions are NOT propagated. See Limitations Reference and Mirroring Considerations.

  • Hardcoded FQDNs — discover via REST API.

PREFER
  • sqlcmd (Go) -G over 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.sql for complex queries — avoids shell escaping.

  • -F vertical for exploration of wide tables.

  • Env vars (FABRIC_SERVER, FABRIC_DB) for script reuse.

TROUBLESHOOTING
SymptomCauseFix
Login failed for userWrong DB name or no accessVerify -d matches the REST properties.databaseName value (see COMMON-CLI.md "Discovering Connection Parameters via REST"), and that you have permission
Cannot open serverWrong FQDN or networkRe-discover via REST API; check port 1433
Login timeout expiredPort 1433 blockednc -zv <endpoint>.database.fabric.microsoft.com 1433; check firewall/VPN
ActiveDirectoryDefault failureaz login expired or wrong tenantRe-authenticate using the Azure CLI troubleshooting/auth guidance in COMMON-CLI.md
Cross-database query failsUsing OLTP endpointSwitch to SQL analytics endpoint for three-part naming
Data appears stale in analytics endpointMirroring replication lagWait for replication; check status via sys.dm_change_feed_log_scan_sessions
Table missing from analytics endpointTable exceeds 1000-table mirror limit, or has unsupported PK type, or uses CCI/in-memory/Always EncryptedCheck sys.dm_change_feed_errors; see mirroring limitations
Column missing from analytics endpointComputed 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 endpointLOB columns > 1 MB are truncated in OneLakeQuery the OLTP endpoint for full LOB data
datetime2(7) precision loss on analytics endpointDelta Lake supports only 6 digits of precision7th fractional digit is trimmed; use OLTP endpoint if precision is critical
RLS/DDM not enforced on analytics endpointSecurity policies not propagated to OneLakeQuery the OLTP endpoint to enforce security policies
Vector search returns no resultsNULL embeddings or dimension mismatchVerify WHERE Embedding IS NOT NULL; check dimensions
RLS not filtering as expectedWrong security predicate or user contextCheck USER_NAME() value; verify policy with sys.security_policies
sys.fn_get_audit_file_v2 returns no rowsAuditing not enabledEnable auditing via REST API (PATCH .../settings/sqlAudit) or Fabric portal
Garbled CSV outputMissing -W or wrong -sAdd -W -s"," -w 4000
(N rows affected) in fileNo SET NOCOUNT ONPrepend SET NOCOUNT ON;
sqlcmd not foundsqlcmd is not installed or not on PATHSee common/COMMON-CLI.md for sqlcmd installation and setup guidance
Login timeout expired on redirectConnection policy requires ports 11000–11999Allow 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.

Download ZIP

The ZIP holds the skill’s files, its licence files and an ATTRIBUTION.md. Download sqldb-cli.zip