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://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/authoring.md

<!-- Mode reference for the `sqldb-cli` skill. Loaded on demand from `skills/sqldb-cli/SKILL.md` when the request matches the `authoring` mode. -->

SQL Database Authoring — CLI Skill

Create and manage SQL database in Fabric items, author T-SQL DDL/DML, deploy schema via SqlPackage, configure source control, CI/CD, and GraphQL APIs using sqlcmd and az rest.

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
SQL Database item definitions (dacpac/sqlproj)ITEM-DEFINITIONS-CORE.md § Per-Item-Type Definitions
SQL Database vs DW capability matrixSQLDB-AUTHORING-CORE.md § SQL Database vs Data Warehouse
Database Lifecycle, Table DDL, Temporal, Views, DML, BCP, Procs/Functions/Triggers, SqlPackage, Source Control, GraphQL, Mirroring, Auditing, CMK, Permissions, Gotchas, Patterns, Decision GuideSQLDB-AUTHORING-CORE.md (all sections)
T-SQL Anti-PatternsSQLDB-AUTHORING-CORE.md § T-SQL Anti-Patterns
Schema Design GuidanceSQLDB-AUTHORING-CORE.md § Schema Design Guidance
Limitations Reference (unsupported features, resource limits)SQLDB-AUTHORING-CORE.md § Limitations Reference
Endpoint SelectionSQLDB-CONSUMPTION-CORE.md § Endpoint Selection
Metadata and Schema DiscoverySQLDB-CONSUMPTION-CORE.md § Metadata and Schema Discovery
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

ToolRoleSetup Reference
sqlcmd (Go)Primary: Execute DDL/DML T-SQL. Standalone binary, no ODBC, built-in Entra ID auth.See COMMON-CLI.md for installation and authentication prerequisites.
sqlpackageSchema deployment (.dacpac), database portability (.bacpac).See COMMON-CLI.md for installation and environment setup prerequisites.
az CLIFabric REST for endpoint discovery and database creation.See COMMON-CLI.md for Azure CLI authentication and token setup.
jqParse JSON from az rest.See COMMON-CLI.md for shared CLI/tooling prerequisites.

Agent check — before first operation, confirm the required CLI tools and authentication are already configured by following the shared setup guidance in COMMON-CLI.md. Do not duplicate install or az login steps in this skill.


Connection

Discover the SQL Database TDS Endpoint

For workspace/item resolution, SQL Database endpoint discovery, and CLI connection patterns, use the shared guidance in common/COMMON-CLI.md and common/COMMON-CORE.md instead of embedding az rest or sqlcmd recipes here.

Follow the SQL Database endpoint discovery steps in COMMON-CLI.md, then bring the discovered server FQDN and database name back into this skill for SQLDB-specific authoring and deployment tasks.

  • Use the SQL Database endpoint values returned by Fabric for the target item; do not hardcode endpoint domains or database names.

  • When generating deployment or authoring steps, treat connectivity details as inputs discovered via the shared common guidance.

  • Focus this skill on schema authoring, DDL/DML design, constraints, indexing, source control, SqlPackage deployment, and GraphQL/API behaviors rather than connection bootstrapping.

Connection guidance

If the user needs help connecting interactively or from CI/CD, refer them to common/COMMON-CLI.md for the shared sqlcmd setup, authentication, and invocation patterns.

For SQLDB-specific authoring in this skill, assume the connection inputs are already known:

  • serverFqdn

  • databaseName


Agentic Workflows

Schema Discovery Before Authoring

Before any write operation, discover the target schema:

# 1. List tables
$SQLCMD -Q "SELECT table_schema, table_name FROM information_schema.tables WHERE table_type='BASE TABLE' ORDER BY 1,2" -W

# 2. Check columns
$SQLCMD -Q "SELECT column_name, data_type, is_nullable, column_default FROM information_schema.columns WHERE table_name='Orders' ORDER BY ordinal_position" -W

# 3. Sample data
$SQLCMD -Q "SELECT TOP 5 * FROM dbo.Orders" -W

# 4. Check constraints
$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_name='Orders' ORDER BY tc.constraint_type" -W

# 5. Check 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

# 6. 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 row_count DESC" -W

# 7. Programmability objects
$SQLCMD -Q "SELECT name, type_desc FROM sys.objects WHERE type IN ('V','FN','IF','P','TF','TR') ORDER BY type_desc, name" -W
Workflow
  1. Discover → Run steps 1–5 to understand available tables/columns.

  2. Sample → SELECT TOP 5 on relevant tables.

  3. Formulate → Select pattern from SQLDB-AUTHORING-CORE.md (Table DDL, Temporal Tables, Data Virtualization, Views, DML, etc.).

  4. Execute → $SQLCMD -Q "..." or $SQLCMD -i file.sql for multi-statement.

  5. Verify → Query affected table (SELECT COUNT(*), SELECT TOP 5).

  6. Deploy (optional) → Extract with sqlpackage /Action:Extract for .dacpac; set up source control.


Gotchas, Rules, Troubleshooting

For full authoring gotchas: SQLDB-AUTHORING-CORE.md Authoring Gotchas and Troubleshooting. For CLI-specific issues: COMMON-CLI.md Gotchas & Troubleshooting (CLI-Specific).

MUST DO
  • Verify workspace has capacity before creating database — call GET /v1/workspaces/{id} and check capacityId.

  • 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 — ActiveDirectoryDefault depends on an authenticated CLI session.

  • Specify collation at creation — cannot be changed after the database is created.

  • Use SqlPackage for repeatable deployments — extract .dacpac → publish for incremental schema changes.

  • Use -i file.sql for multi-statement batches (CREATE PROCEDURE, transactions with GO separators).

  • SET NOCOUNT ON; in scripts — suppresses row-count messages that corrupt output.

AVOID
  • ODBC sqlcmd (/opt/mssql-tools/bin/sqlcmd) — use the Go version.

  • Omitting -W in scripts — trailing spaces corrupt CSV.

  • Hardcoded FQDNs — discover via REST API.

  • MARS — not supported. Remove MultipleActiveResultSets.

  • CREATE LOGIN / SQL authentication — Entra users only.

  • Modifying tables with CCI / ALTER INDEX ALL while mirroring is active — stop mirroring or alter individual indexes.

  • vector / json columns on tables that must mirror — cannot be mirrored to OneLake.

  • Special characters in DB / column names — see Limitations Reference.

  • Modifying .sqlproj in source-controlled repo — reset on next sync.

  • Unsupported features (CDC, Always Encrypted, in-memory, ledger, full-text GA, partition SWITCH, EXECUTE AS, hierarchyid/sql_variant/timestamp PKs, CTAS, COPY INTO) — see Limitations Reference for the full list.

  • Exceeding resource limits (32 vCores, 4 TB, 1024 GB tempdb, 150 DBs/workspace).

PREFER
  • az rest for database creation over portal — scriptable and repeatable.

  • SqlPackage publish (.dacpac) over manual DDL for schema evolution — tracks incremental changes.

  • Enforced constraints (PK, FK, CHECK, DEFAULT) — SQL Database supports them fully, unlike DW.

  • Temporal tables for audit trails and slowly-changing dimensions — full system-versioning available. Note: history table is excluded from mirroring.

  • Data virtualization (external tables / OPENROWSET) to query OneLake without ETL. Note: external tables themselves are not mirrored.

  • INSERT ... SELECT for bulk data movement within the database.

  • BCP for high-performance bulk import/export.

  • Native AI functions / sp_invoke_external_rest_endpoint for embedding generation in T-SQL.

  • sqlcmd (Go) -G over curl+token for SQL queries.

  • -Q (non-interactive exit) for agentic use.

  • -i file.sql over -Q "..." for anything beyond simple one-liners.

  • -F vertical for exploration of wide tables.

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

  • Auto-tuning — let the engine manage indexes; check sys.dm_db_tuning_recommendations periodically.

  • Optimized locking — enabled by default; reduces lock memory and eliminates lock escalation.

TROUBLESHOOTING
SymptomFix
SqlPackage auth errorUse Authentication=Active Directory Default in connection string
Login failed for userVerify -d matches database display name exactly (case-sensitive)
Cannot open server / Login timeout expiredRe-discover FQDN via REST API; check port 1433 / firewall
ActiveDirectoryDefault failureaz login session may be expired — refresh Azure CLI authentication per common/COMMON-CLI.md
Collation error after creationCannot change — must recreate database with desired collation
Foreign key violation on INSERTCheck referenced table has matching row; verify column types
Vector insert dimension mismatchEnsure vector literal has exactly the declared dimensions
CCI creation fails on existing tableStop mirroring, create index, restart mirroring. CCI created inline with CREATE TABLE also prevents mirroring of that table
Table not mirrored after DDL changeDDL changes trigger a full data reseed; table with unsupported PK type or >1000 tables are skipped
Vector/json column prevents mirroringTables with vector or json columns cannot be mirrored; use OLTP endpoint to query these
Computed columns missing from analytics endpointComputed columns are skipped during mirroring
LOB data truncated on analytics endpointLOB columns > 1 MB are truncated in OneLake
ALTER INDEX ALL failsNot allowed while mirroring is active; alter individual indexes by name
Garbled CSV / (N rows affected) in fileAdd -W -s"," -w 4000; prepend SET NOCOUNT ON;
sp_invoke_external_rest_endpoint 401Create/verify database-scoped credential for target URL
sqlcmd not foundEnsure sqlcmd is installed and on PATH; follow the shared CLI setup guidance in common/COMMON-CLI.md
Connection fails on redirect portsConnection policy requires ports 11000–11999 open 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