Generated banner for Sqldw CLI
Generated logo for Sqldw CLI

Sqldw CLI

MicrosoftOfficialPublished by Microsoft

  • Skill
  • Tool integration
  • Data and AI
  • MIT
  • No issues found

From the author

Manage Fabric Warehouse, Lakehouse SQL endpoints, and Mirrored Databases: DDL/DML, COPY INTO, read-only T-SQL, Query Insights diagnostics, and Capacity Metrics CU-spike correlation. Synapse migration target SQL belongs to synapse-migration; Fabric SQL database belongs to sqldb-cli. Triggers: query warehouse, create warehouse table, failed or canceled query, CU spike, Capacity Metrics app, custom SQL pool, Lakehouse table health.
— the description by Microsoft

AutoGineer summary

Written by AutoGineer from the skill’s own files, not by the author

The sqldw-cli skill provides a structured interface for interacting with Microsoft Fabric data storage items, including Warehouses, Lakehouse SQL analytics endpoints, and Mirrored Databases. It operates through three distinct modes—authoring, consumption, and operations—to handle T-SQL execution, data ingestion, and performance diagnostics. The skill relies on the fabric-sqlendpoint-execute_query MCP tool for data-plane operations and requires users to consult specific mode references to ensure correct T-SQL syntax and operational constraints.

What it does

  • Executes DDL and DML statements for schema management and data manipulation in Fabric Warehouses.
  • Supports data ingestion via COPY INTO and OPENROWSET patterns.
  • Provides read-only querying capabilities for data exploration and metadata discovery.
  • Enables performance diagnostics using Query Insights and capacity metrics correlation.
  • Facilitates Lakehouse table health monitoring and diagnostic reporting.
  • Dispatches requests to specialized modes based on user intent to ensure safe and accurate execution.

When to use it

  • When you need to create, modify, or drop tables and schemas within a Fabric Warehouse.
  • When performing bulk data ingestion from external storage into a Warehouse.
  • When querying data or metadata from a Warehouse, Lakehouse SQL endpoint, or Mirrored Database.
  • When investigating performance issues, such as slow queries or CU spikes, using diagnostic views.
  • When correlating capacity consumption with specific SQL queries or users.

Advantages

  • Centralizes management of diverse Fabric SQL-based data items under a single skill.
  • Enforces mode-specific safety boundaries to prevent accidental mutations in read-only contexts.
  • Provides clear diagnostic paths for performance tuning and capacity management.
  • Standardizes T-SQL execution through a dedicated MCP tool interface.
  • Includes mandatory telemetry headers for consistent tracking across Fabric API calls.

Usage examples

“How many rows are in the nyctlc table in SkillsTestWarehouse?”
The agent selects the consumption mode, reads the consumption reference, and executes a SELECT COUNT(*) query via the MCP tool to return the exact row count.
“Create dbo.Orders in the warehouse with OrderId, CustomerId and OrderDate.”
The agent selects the authoring mode, reads the authoring reference, executes the CREATE TABLE statement, and performs a readback query to confirm the table exists.
“Which queries are slowest, and which tables should I cluster?”
The agent selects the operations mode, reads the operations reference, and executes diagnostic queries against queryinsights to identify slow-running patterns.

Install

  1. Download the skill as a ZIP:

    https://autogineer.com/agent-skills/microsoft/sqldw-cli/download
  2. Unzip it into the cross-client skills folder of your project:

    mkdir -p .agents/skills && unzip sqldw-cli.zip -d .agents/skills

Documentation by Microsoft

Telemetry — MANDATORY. Every api.fabric.microsoft.com call must carry x-ms-fabric-skill: sqldw-cli (az rest: --headers "x-ms-fabric-skill=sqldw-cli"), including every LRO poll, fabric_lro and retry. Snippets omit it — add it anyway. This covers all three modes; the mode references inherit it.

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 sqldw-cli for T-SQL sent to a Warehouse, a Lakehouse SQL analytics endpoint, or a Mirrored Database, including plain Lakehouse table SELECT, row-count, filtering, and aggregation requests. Target Warehouse SQL executed within an end-to-end Azure Synapse or Dedicated SQL Pool migration belongs to synapse-migration; standalone Warehouse work before or after migration returns to sqldw-cli. Any notebook-cell or PySpark DataFrame work is spark-cli; a Fabric SQL database (OLTP) is sqldb-cli.

Fabric Warehouse and SQL Endpoints — CLI Skill

This one skill owns Fabric Warehouse, Lakehouse SQL analytics endpoints and Mirrored Databases: T-SQL authoring and ingestion, read-only querying, and warehouse 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 T-SQL surface area, DDL constraints, query templates and gotchas; acting without it produces invalid T-SQL and wrong results.

Mode selection

ModeUse when the request ...Example triggersRead this first
authoringchanges warehouse state: table DDL, DML, ingestion, transactions, procedures, schema evolution, time travelcreate warehouse table, COPY INTO, OPENROWSET, INSERT/UPDATE/DELETE, warehouse MERGE, CTAS, sp_rename, create T-SQL procedure, warehouse time travelreferences/authoring.md
consumptionreads data or metadata: SELECT, row counts, filtering, aggregation, schema/object discovery, CSV exportquery warehouse, count rows lakehouse, SELECT lakehouse, show tables, describe warehouse schema, export SQL datareferences/consumption.md
operationsdiagnoses performance, failures, capacity consumption, SQL pool usage, or health through queryinsights and supported endpoint diagnosticsfailed or canceled warehouse queries, CU spike, Capacity Metrics app, expensive SQL users, custom SQL pool recommendation, queryinsights CPU, pressure events, cache warmth, Lakehouse tables needing attentionreferences/operations.md

Operations reference index

Read references/operations.md first for any operations request, then open the matching leaf directly from this index. Do not chain from links inside a leaf; for composite requests, follow scenarios.md only to the additional leaves that this index links directly.

RequestRead this leaf reference
composite operations scenarios such as why is my warehouse slow, performance degradation, optimization, or what are people runningreferences/operations/scenarios.md
slow-query summaries, top users, recent queries, pattern search, runtime profiles, cluster-key candidatesreferences/operations/query-reference.md
failed or canceled requests, error codes, recurring non-successful query shapesreferences/operations/failure-analysis.md
SQL pool pressure windows and overlapping requestsreferences/operations/pool-pressure.md
CPU concentration, regressions, repeated expensive queries, cache interpretationreferences/operations/resource-consumers.md
Lakehouse Delta file health and tables needing maintenancereferences/operations/lakehouse-health.md
Capacity Metrics CU spike, costly item, SQL query/user correlationreferences/operations/capacity-metrics-correlation.md — start at section 1
custom SQL pool recommendation for an already identified SQL endpointreferences/operations/capacity-metrics-correlation.md — skip FabricIQ and start at section 6
Mode boundary rule

Classify by intent, not by endpoint — all three modes issue the same execute_query call.

  • A schema-discovery SELECT run to plan a CREATE TABLE belongs to authoring, even though it only reads.

  • A SELECT that answers the user's question is consumption.

  • A query against queryinsights.* or a supported diagnostic such as Lakehouse sys.sp_get_table_health_metrics is operations; a SELECT against user tables is not, however slow it is.

consumption and operations are read-only. 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 drafting the T-SQL is NOT completing the task. If you did not send the statement, nothing changed — say so explicitly rather than reporting success.

ModeTerminal write
authoringThe DDL/DML itself, sent through execute_query. Follow it with a readback in a second call (SELECT ... FROM INFORMATION_SCHEMA.TABLES after CREATE, SELECT COUNT(*) after DML) and report the object you created or changed under the name the user asked for. Only a Warehouse accepts table DDL/DML — see the mode reference for what a Lakehouse SQL endpoint and a Mirrored Database allow.
consumptionnone — this mode is read-only
operationsnone — read-only, but you must still run the diagnostic statements: every figure comes from a SELECT or documented read-only diagnostic procedure executed in the turn you report it, cited inline with its source view or procedure, never carried forward from an earlier turn. The only allowed diagnostic EXEC is sys.sp_get_table_health_metrics on a Lakehouse SQL analytics endpoint. Never execute ALTER, CREATE or DROP yourself, even when the diagnosis is certain.
consumption and operations reporting

Neither read-only mode has a terminal write, so its deliverable is the answer itself. Run the query against the live endpoint and report the real rows — a summary of the reference does not answer the request.

In operations, name the source view, catalog, or procedure each figure came from right next to it (for example 2,140 ms (queryinsights.long_running_queries) or 268 files (sys.sp_get_table_health_metrics)), including when the answer is zero rows. Re-run the diagnostic in the turn you report it rather than restating an earlier turn's output. Never fabricate, assume or infer diagnostic numbers.

Shared essentials (all modes)

Every mode reaches the data plane the same way. Resolve the workspace and item first, then send T-SQL through the MCP tool.

Execution surface — fabric-sqlendpoint-execute_query

All T-SQL runs through the fabric-sqlendpoint-execute_query MCP tool. For SQL data-plane execution this skill supersedes the COMMON-CLI SQL/TDS guidance — use the MCP tool, not sqlcmd, unless you are explicitly on the documented Legacy CLI Fallback path (see the mode reference). az rest stays the right tool for control-plane discovery.

fabric-sqlendpoint-execute_query(workspaceId, itemId, query)
  • Preflight, before the first operation of any mode: confirm a tool whose name ends in execute_query is in your tool list. It comes from the fabric-sqlendpoint MCP server, registered by a Fabric skills plugin or this repo's .mcp.json. The concrete name may be prefixed (fabric-sqlendpoint-execute_query, sqlendpoint-global-execute_query) — invoke the name you actually see. If none is present, say so, then fall back to the Legacy CLI Fallback (TDS client) documented in the mode reference; tell the user they can register the server for the primary path — see mcp-setup/. Exception: the Capacity Metrics correlation workflow is intentionally limited to the existing FabricIQ and SQL Endpoint MCP surfaces; if SQL Endpoint MCP is unavailable, report that phase as blocked and do not use the legacy fallback.

  • itemId is a GUID, never an FQDN or -d <DatabaseName>. For a Warehouse or a Mirrored Database use the item id; for a Lakehouse use properties.sqlEndpointProperties.id, not the Lakehouse item id.

  • One T-SQL batch per call. No GO separators, no sqlcmd meta-commands (:setvar, :r, -i). Split multi-batch work into separate calls. Only the last result set comes back.

  • Results cap at 10,000 rows and queries time out at 300s, with a 20 requests/min rate limit. Use TOP N, WHERE or aggregation; exactly 10,000 rows means the result was truncated. These are observed defaults, not a documented contract.

Common references
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
Fabric Control-Plane API via az restCOMMON-CLI.mdAlways pass --resource; pagination and LRO helpers
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.

  • For a focused operations request, read its one matching leaf after references/operations.md. For a composite request, read references/operations/scenarios.md, then each focused leaf named by that scenario; read every file once in full.

  • Resolve workspace and item ids by listing and filtering, never by guessing a GUID.

  • Execute T-SQL through fabric-sqlendpoint-execute_query whenever that tool is available; drop to the Legacy CLI Fallback documented in the mode reference only when it is not.

  • 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 statements against the live endpoint and report the real results. Quoting what the reference says instead of executing it does not answer the request.

  • Produce every artefact the user asked for, under the name they used, and keep its heading even when the finding is "none", "zero rows" or "not applicable".

PREFER
  • The narrowest mode that satisfies the request.

  • Reading exactly one mode reference plus the minimum directly indexed operations leaves required by the selected focused or composite scenario.

  • Reporting the mode you chose in your first response so the user can correct you.

  • Labelling queries with OPTION (LABEL = '...') so the run is traceable in Query Insights.

  • Consolidating related statements into fewer calls — the rate limit is per identity, not per query.

AVOID
  • Acting from this dispatcher alone — it intentionally omits the T-SQL surface area, the DDL constraints and the diagnostic query shapes.

  • 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 anything while in a read-only mode (consumption, operations).

  • Unbounded SELECT * — it silently truncates at 10,000 rows.

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

Examples

User requestModeReference to read
"How many rows are in the nyctlc table in SkillsTestWarehouse?"consumptionreferences/consumption.md
"Create dbo.Orders in the warehouse with OrderId, CustomerId and OrderDate."authoringreferences/authoring.md
"Load Files/nyctlc_sample.csv from OneLake into the warehouse with COPY INTO."authoringreferences/authoring.md
"Which queries are slowest, and which tables should I cluster?"operationsreferences/operations.md
"Show me the average trip distance per vendor from the lakehouse SQL endpoint."consumptionreferences/consumption.md

Files

references/authoring.md

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

MODE-CRITICAL NOTES (authoring mode)

  1. Table DDL, DML, COPY INTO / OPENROWSET ingestion, transactions and time travel are Warehouse-only. A Lakehouse SQL analytics endpoint and a Mirrored Database are read-only for table data — only views, functions, procedures and schemas can be authored there.

  2. Reading the reference is not authoring. Every mutation ends with a fabric-sqlendpoint-execute_query call that runs the DDL/DML, followed by a readback query proving it landed.

sqldw-cli authoring mode — Fabric Warehouse and SQL Endpoint T-SQL Authoring

⚠️ SQL Execution Override: For SQL data-plane execution, this skill supersedes COMMON-CLI SQL/TDS guidance. Use MCP fabric-sqlendpoint-execute_query (see Tool Stack) unless explicitly using Legacy CLI Fallback.

Table of Contents

TaskReferenceNotes
Finding Workspaces and Items in FabricCOMMON-CLI.md § Finding Workspaces and Items in FabricMandatory — READ link first [needed for finding workspace id by its name or item id by its name, item type, and workspace id]
Fabric Topology & Key ConceptsCOMMON-CORE.md § Fabric Topology & Key Concepts
Environment URLsCOMMON-CORE.md § Environment URLs
Authentication & Token AcquisitionCOMMON-CORE.md § Authentication & Token AcquisitionWrong audience = 401; read before any auth issue
Core Control-Plane REST APIsCOMMON-CORE.md § Core Control-Plane REST APIsIncludes pagination, LRO polling, and rate-limiting patterns
OneLake Data AccessCOMMON-CORE.md § OneLake Data AccessRequires storage.azure.com token, not Fabric token
Definition EnvelopeITEM-DEFINITIONS-CORE.md § Definition EnvelopeDefinition payload structure
Per-Item-Type DefinitionsITEM-DEFINITIONS-CORE.md § Per-Item-Type DefinitionsSupport matrix, decoded content, part paths — REST specs, CLI recipes
Job ExecutionCOMMON-CORE.md § Job Execution
Capacity ManagementCOMMON-CORE.md § Capacity Management
Gotchas, Best Practices & Troubleshooting (Platform)COMMON-CORE.md § Gotchas, Best Practices & Troubleshooting
Tool Selection RationaleCOMMON-CLI.md § Tool Selection Rationale
Authentication RecipesCOMMON-CLI.md § Authentication Recipesaz login flows and token acquisition
Fabric Control-Plane API via az restCOMMON-CLI.md § Fabric Control-Plane API via az restAlways pass --resource; includes pagination and LRO helpers
OneLake Data Access via curlCOMMON-CLI.md § OneLake Data Access via curlUse curl not az rest (different token audience)
SQL / TDS Data-Plane AccessCOMMON-CLI.md § SQL / TDS Data-Plane AccessLegacy sqlcmd reference (MCP is primary — see Tool Stack)
Job Execution (CLI)COMMON-CLI.md § Job Execution
OneLake ShortcutsCOMMON-CLI.md § OneLake Shortcuts
Capacity Management (CLI)COMMON-CLI.md § Capacity Management
Composite RecipesCOMMON-CLI.md § Composite Recipes
Gotchas & Troubleshooting (CLI-Specific)COMMON-CLI.md § Gotchas & Troubleshooting (CLI-Specific)az rest audience, shell escaping, token expiry
Quick ReferenceCOMMON-CLI.md § Quick Referenceaz rest template + token audience/tool matrix
Item-Type Capability MatrixSQLDW-CONSUMPTION-CORE.md § Item-Type Capability MatrixShows read-only (SQLEP) vs read-write (DW)
Connection FundamentalsSQLDW-CONSUMPTION-CORE.md § Connection FundamentalsTDS, port 1433, Entra-only, no MARS
Supported T-SQL Surface Area (Consumption Focus)SQLDW-CONSUMPTION-CORE.md § Supported T-SQL Surface AreaRead before writing T-SQL — includes data types (no nvarchar/datetime/money)
Read-Side Objects You Can CreateSQLDW-CONSUMPTION-CORE.md § Read-Side Objects You Can CreateViews, TVFs, scalar UDFs, procedures
Temporary TablesSQLDW-CONSUMPTION-CORE.md § Temporary Tables
Cross-Database QueriesSQLDW-CONSUMPTION-CORE.md § Cross-Database Queries3-part naming, same workspace only
Security for ConsumptionSQLDW-CONSUMPTION-CORE.md § Security for ConsumptionGRANT/DENY, RLS, CLS, DDM
Monitoring and DiagnosticsSQLDW-CONSUMPTION-CORE.md § Monitoring and DiagnosticsIncludes query labels; DMVs (live) + queryinsights.* (30-day history)
Performance: Best Practices and TroubleshootingSQLDW-CONSUMPTION-CORE.md § Performance: Best Practices and TroubleshootingStatistics, caching, clustering, query tips
REST API: Refresh SQL Endpoint MetadataSQLDW-CONSUMPTION-CORE.md § REST API: Refresh SQL Endpoint MetadataForce metadata sync when SQLEP is stale after ETL
System Catalog Queries (Metadata Exploration)SQLDW-CONSUMPTION-CORE.md § System Catalog Queriessys.tables, sys.columns, sys.views, sys.stats
Common Consumption PatternsSQLDW-CONSUMPTION-CORE.md § Common Consumption PatternsReporting views, cross-DB analytics, temp table staging
Gotchas and Troubleshooting (Consumption)SQLDW-CONSUMPTION-CORE.md § Gotchas and Troubleshooting Reference18 numbered issues with cause + resolution
Quick Reference: Consumption CapabilitiesSQLDW-CONSUMPTION-CORE.md § Quick Reference: Consumption Capabilities
Authoring Capability MatrixSQLDW-AUTHORING-CORE.md § Authoring Capability MatrixRead first — DW vs SQLEP authoring scope
Table DDL (DW Only)SQLDW-AUTHORING-CORE.md § Table DDL (DW Only)CREATE, CTAS, ALTER, sp_rename, DROP, constraints, schema evolution, IDENTITY
DML Operations (DW Only)SQLDW-AUTHORING-CORE.md § DML Operations (DW Only)INSERT...SELECT, UPDATE, DELETE, TRUNCATE, MERGE
Data Ingestion (DW Only)SQLDW-AUTHORING-CORE.md § Data Ingestion (DW Only)COPY INTO, OPENROWSET, method comparison
Transactions (DW Only)SQLDW-AUTHORING-CORE.md § Transactions (DW Only)Snapshot isolation only; write-write conflict rules
Stored Procedures (Authoring Patterns)SQLDW-AUTHORING-CORE.md § Stored Procedures (Authoring Patterns)ETL procs, upsert, CTAS swap, cursor replacement
Time Travel and Warehouse SnapshotsSQLDW-AUTHORING-CORE.md § Time Travel and Warehouse Snapshots (DW Only)FOR TIMESTAMP AS OF; 30-day retention; snapshots GA
Source Control and CI/CDSQLDW-AUTHORING-CORE.md § Source Control and CI/CD (DW Only — Preview)Git integration, SQL DB projects, deployment pipelines
Authoring Permission ModelSQLDW-AUTHORING-CORE.md § Authoring Permission ModelContributor minimum for DDL/DML; Admin for GRANT
Authoring Gotchas and TroubleshootingSQLDW-AUTHORING-CORE.md § Authoring Gotchas and Troubleshooting17-row issue/cause/resolution table
Common Authoring PatternsSQLDW-AUTHORING-CORE.md § Common Authoring PatternsIncremental load, SCD Type 1, SQLEP view layer
Quick Reference: Authoring Decision GuideSQLDW-AUTHORING-CORE.md § Quick Reference: Authoring Decision GuideScenario → recommended approach lookup
Core Authoring via MCPauthoring-cli-quickref.md § Core Authoring via MCPTable DDL, DML, data ingestion via execute_query
Advanced Authoring Patterns via MCPauthoring-cli-quickref.md § Advanced Authoring Patterns via MCPTransactions, schema evolution, stored procedures, time travel
MCP Workflow Templatesauthoring-script-templates.md § MCP Workflow TemplatesCOPY INTO, ELT pipeline, upsert with retry, schema migration, time travel recovery
Tool StackSKILL.md § Tool Stackfabric-sqlendpoint-execute_query MCP tool + az CLI; verify before first op
ConnectionSKILL.md § ConnectionworkspaceId/itemId discovery, execute example
Query Executionauthoring-cli-quickref.md § Query ExecutionMCP tool call format, batch considerations
Agentic WorkflowsSKILL.md § Agentic WorkflowsStart here — discover schema before any write
Monitoring Authoring Operationsauthoring-cli-quickref.md § Monitoring Authoring OperationsActive DML/DDL, recent ETL, failed writes
Gotchas, Rules, TroubleshootingSKILL.md § Gotchas, Rules, TroubleshootingMUST DO / AVOID / PREFER checklists
Agent Integration Notesauthoring-cli-quickref.md § Agent Integration NotesPlatform-specific tips (Copilot CLI, Claude Code)

Tool Stack

ToolRoleInstall
fabric-sqlendpoint-execute_query MCP toolPrimary: Execute DDL/DML T-SQL queries against Fabric SQL Endpoints. Returns CSV results. Auth handled by MCP protocol.No install — server-side. Requires MCP server registration.
az CLIAuth (az login), Fabric REST for workspace/item discovery, snapshot management.Pre-installed in most dev environments
jqParse JSON from az restPre-installed or trivial

IMPORTANT — MCP vs sqlcmd: This skill uses the fabric-sqlendpoint-execute_query MCP tool for all T-SQL execution. Do not use COMMON-CLI SQL/TDS/sqlcmd sections for query execution.

Agent preflight — verify before first operation:

  1. Confirm the fabric-sqlendpoint-execute_query tool is available in your tool list. This tool is provided by the fabric-sqlendpoint MCP server, which is registered either by installing a Fabric skills plugin (the path for end users) or via this repo's .mcp.json — other MCP clients may register it through their own configuration.

  2. If no tool matches, the user must register the Fabric SQL Endpoint MCP server. See MCP setup.

    • Global URL: https://api.fabric.microsoft.com/v1/mcp/dataPlane/sqlEndpoint

    • Item-scoped URL: https://api.fabric.microsoft.com/v1/mcp/dataPlane/workspaces/{workspaceId}/items/{itemId}/sqlEndpoint

MCP Tool Signature
fabric-sqlendpoint-execute_query(workspaceId, itemId, query)

Tool name may differ: execute_query is the logical operation. Depending on how the server is registered, the concrete tool name in your tool list may be prefixed (e.g. fabric-sqlendpoint-execute_query or sqlendpoint-global-execute_query). Invoke the concrete name shown in your tool list, always passing workspaceId, itemId, and query.

ParameterTypeDescription
workspaceIdstring (UUID)The workspace GUID containing the target item
itemIdstring (UUID)The Fabric item GUID to target. For a Warehouse, use the item id. For a Lakehouse, use its SQL analytics endpoint id (properties.sqlEndpointProperties.id) — not the Lakehouse item id.
querystringT-SQL query text (single batch — no GO separators or sqlcmd meta-commands)

Returns: CSV resource (RFC 4180) with tabular results + metadata text.

Batch guidance: Multiple statements without GO are allowed in one call (e.g., CREATE TABLE ...; INSERT INTO ...). However, only the last result set is returned, and an error in any statement fails the entire batch. Prefer separate fabric-sqlendpoint-execute_query calls for independent DDL/DML operations — this gives clearer error messages and lets you verify each step succeeded before proceeding.

MCP Limits
LimitValueNotes
Max rows returned10,000For DDL/DML, row count metadata indicates affected rows
Query timeout300 secondsLong-running operations may timeout
Rate limit20 requests/min per identityHTTP 429 returned when exceeded

These values are observed defaults, not a documented contract — the MCP service can change them. Treat them as guidance and confirm the current behavior from live 429 / timeout / truncation responses (or Microsoft Learn, if/when published) rather than relying on the exact numbers.

Authoring Scope by Item Type
CapabilityWarehouse (DW)Lakehouse/Mirrored DB SQLEP
Table DDL (CREATE/ALTER/DROP)✅❌
DML (INSERT/UPDATE/DELETE/MERGE)✅❌
COPY INTO, OPENROWSET (ingest)✅OPENROWSET read-only
Transactions✅❌
Time travel, snapshots✅❌
CREATE VIEW/FUNCTION/PROCEDURE✅✅
CREATE SCHEMA✅✅
Fabric DW DDL Constraints

These constraints are hard requirements — violating them produces errors:

ConstraintDetails
No DEFAULT in CREATE TABLEDefault values not supported. Set defaults in application/INSERT logic.
No PRIMARY KEY inside CREATE TABLEMust add via ALTER TABLE ... ADD CONSTRAINT ... PRIMARY KEY NONCLUSTERED (col) NOT ENFORCED
DATETIME2 requires precisionAlways use DATETIME2(6), never bare DATETIME2
Unsupported data typesNCHAR, NVARCHAR, TEXT, IMAGE, MONEY, SMALLMONEY, DATETIME — use VARCHAR, DECIMAL, DATETIME2(6) instead
No WITH DISTRIBUTIONDistribution is automatic in Fabric
Constraints must be NOT ENFORCEDPRIMARY KEY NONCLUSTERED NOT ENFORCED, UNIQUE NONCLUSTERED NOT ENFORCED, FOREIGN KEY NOT ENFORCED
PK columns must be NOT NULLDeclare PK columns as NOT NULL in CREATE TABLE before adding PK constraint
ALTER TABLE scopeAdd/drop nullable columns (must specify NULL) and add/drop constraints (NOT ENFORCED only) are GA; ALTER COLUMN type changes are in preview (see note below)

MERGE and ALTER COLUMN are NOT hard errors. Per T-SQL surface area, MERGE is a generally available Warehouse feature and ALTER TABLE ... ALTER COLUMN is in preview. Prefer an explicit DELETE+INSERT when snapshot-conflict isolation matters, and CTAS + sp_rename for production-critical column-type changes — as a robustness choice, not because the syntax is blocked.

Correct CREATE TABLE pattern:

CREATE TABLE dbo.Orders (
    OrderID INT NOT NULL,
    CustomerName VARCHAR(100) NULL,
    Amount DECIMAL(19,4) NULL,
    CreatedAt DATETIME2(6) NULL
)
ALTER TABLE dbo.Orders ADD CONSTRAINT PK_Orders PRIMARY KEY NONCLUSTERED (OrderID) NOT ENFORCED

Additional supported patterns:

  • CREATE TABLE [dbo].[clone] AS CLONE OF [dbo].[source] — duplicate table structure + data

  • COPY INTO — highest-throughput ingestion from external storage


Connection

Discover workspaceId and itemId

You need the workspace GUID and item GUID to call fabric-sqlendpoint-execute_query:

# 1. Find workspace ID by name (capture into WS_ID for the next call)
WS_ID=$(az rest --method get \
  --resource "https://api.fabric.microsoft.com" \
  --url "https://api.fabric.microsoft.com/v1/workspaces" \
  --query "value[?displayName=='MyWorkspace'].id" --output tsv)
echo "Workspace ID: $WS_ID"

# 2. Find warehouse item ID by name
az rest --method get \
  --resource "https://api.fabric.microsoft.com" \
  --url "https://api.fabric.microsoft.com/v1/workspaces/$WS_ID/warehouses" \
  --query "value[?displayName=='MyWarehouse'].id" --output tsv

# For a Lakehouse SQL endpoint, pass its SQL analytics endpoint id — NOT the lakehouse item id
az rest --method get \
  --resource "https://api.fabric.microsoft.com" \
  --url "https://api.fabric.microsoft.com/v1/workspaces/$WS_ID/lakehouses" \
  --query "value[?displayName=='MyLakehouse'].properties.sqlEndpointProperties.id" --output tsv
Execute a Query
fabric-sqlendpoint-execute_query(
  workspaceId: "aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee",
  itemId: "11111111-2222-3333-4444-555555555555",
  query: "CREATE TABLE dbo.FactSales (SaleID bigint NOT NULL, Amount decimal(19,4) NOT NULL)"
)

No additional connection setup needed — authentication is handled transparently by the MCP protocol.

Verifying DDL/DML Results

For DDL (CREATE/ALTER/DROP), the tool returns success with metadata. Always verify:

# After CREATE TABLE, verify it exists
fabric-sqlendpoint-execute_query(workspaceId, itemId, "SELECT table_schema, table_name FROM INFORMATION_SCHEMA.TABLES WHERE table_name = 'FactSales'")

# After DML, check row count
fabric-sqlendpoint-execute_query(workspaceId, itemId, "SELECT COUNT(*) AS row_count FROM dbo.FactSales")

Agentic Workflows

Schema Discovery Before Authoring

Before any write operation, discover the target schema:

# 1. List tables
fabric-sqlendpoint-execute_query(workspaceId, itemId, "SELECT table_schema, table_name FROM INFORMATION_SCHEMA.TABLES ORDER BY 1,2")

# 2. Check columns
fabric-sqlendpoint-execute_query(workspaceId, itemId, "SELECT column_name, data_type, is_nullable FROM INFORMATION_SCHEMA.COLUMNS WHERE table_name='FactSales' ORDER BY ordinal_position")

# 3. Sample data
fabric-sqlendpoint-execute_query(workspaceId, itemId, "SELECT TOP 5 * FROM dbo.FactSales")

# 4. Check constraints
fabric-sqlendpoint-execute_query(workspaceId, itemId, "SELECT constraint_name, constraint_type FROM INFORMATION_SCHEMA.TABLE_CONSTRAINTS WHERE table_name='FactSales'")

# 5. Row counts
fabric-sqlendpoint-execute_query(workspaceId, itemId, "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")

# 6. Programmability objects
fabric-sqlendpoint-execute_query(workspaceId, itemId, "SELECT name, type_desc FROM sys.objects WHERE type IN ('V','FN','IF','P','TF') ORDER BY type_desc, name")
Agentic Workflow
  1. Discover → Run steps 1–4 to understand available tables/columns.

  2. Sample → SELECT TOP 5 on relevant tables.

  3. Formulate → Select pattern from SQLDW-AUTHORING-CORE.md (Table DDL through Common Authoring Patterns).

  4. Execute → Call fabric-sqlendpoint-execute_query(workspaceId, itemId, query). For multi-batch operations (e.g., CREATE PROCEDURE with BEGIN/END), use a single batch without GO.

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

  6. Optionally follow up → Run additional queries to confirm schema changes.


Gotchas, Rules, Troubleshooting

For full authoring gotchas: SQLDW-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 warehouse — call GET /v1/workspaces/{id} and check capacityId.

  • Verify fabric-sqlendpoint-execute_query MCP tool is available — check the tool list before the first operation. If unavailable, instruct the user to register the MCP server.

  • Discover workspaceId and itemId first — resolve the target Warehouse via az rest; the tool takes GUIDs, not an FQDN or -d <DatabaseName>.

  • az login first (for discovery) — the az rest workspace/warehouse lookups need an Azure CLI session. The fabric-sqlendpoint MCP server itself ships headerless and authenticates via your MCP client's native Fabric session, not the Azure CLI token; no signed-in session → auth failure on either path.

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

  • Send a single T-SQL batch per call — no GO separators and no -i file.sql; split multi-batch work (CREATE PROCEDURE, multi-step transactions) into separate fabric-sqlendpoint-execute_query calls.

  • Label authoring queries with OPTION (LABEL = 'ETL_description').

  • Use explicit CAST() in CTAS to control output types.

  • Keep transactions short — long transactions increase conflict window.

AVOID
  • GO separators — the MCP tool accepts only a single T-SQL batch. Combine related DDL in one statement or call fabric-sqlendpoint-execute_query multiple times.

  • sqlcmd meta-commands (:setvar, :r, -i) — not available in MCP tool. Inline all SQL in the query parameter.

  • Unbounded SELECT * — 10,000 row limit. Always use TOP N or WHERE to limit result sets.

  • Singleton INSERT ... VALUES at scale — creates tiny Parquet files. Use INSERT...SELECT, CTAS, or COPY INTO.

  • DROP TABLE IF EXISTS + CREATE TABLE to refresh — loses time-travel history. Use TRUNCATE TABLE + INSERT INTO.

  • MERGE in production — GA, but table-level snapshot-conflict detection makes concurrent writers likely to fail. Prefer DELETE + INSERT when isolation matters.

  • ALTER COLUMN in production — in preview; prefer CTAS + sp_rename for production-critical column-type changes (Schema Evolution).

  • Variables in CTAS — not allowed. Wrap in dynamic SQL: EXEC sp_executesql N'CREATE TABLE ...'.

  • DML on Lakehouse/Mirrored DB SQLEP — read-only for table data. Only views/funcs/procs can be authored.

  • Concurrent UPDATE/DELETE on same table — snapshot isolation conflicts at table level. Serialize writes.

  • Rapid-fire MCP calls — rate limit is 20 req/min. Consolidate multiple statements into one batch where possible.

  • MARS — not supported. Remove MultipleActiveResultSets from connection strings.

PREFER
  • CTAS over CREATE TABLE + INSERT — parallel, single-operation.

  • INSERT ... SELECT over singleton INSERTs.

  • COPY INTO for external file ingestion — highest throughput.

  • DELETE + INSERT over MERGE for upserts in production.

  • TRUNCATE TABLE over DELETE FROM without WHERE — faster, preserves history.

  • Consolidating related DDL into a single fabric-sqlendpoint-execute_query call when no GO is required between statements.

  • CTAS + sp_rename for large-scale transforms instead of UPDATE.

  • fabric-sqlendpoint-execute_query MCP tool over sqlcmd for all T-SQL operations.

  • SET NOCOUNT ON; prefix — reduces metadata noise in results.

  • TOP N or WHERE clauses — stay within 10K row limit.

TROUBLESHOOTING
SymptomFix
Error 24556/24706 snapshot conflictSerialize writes to same table; retry with backoff
COPY INTO auth errorGrant Storage Blob Data Reader on ADLS; or SAS in CREDENTIAL
COPY INTO from OneLake failsProvision workspace identity; check firewall rules
CTAS unexpected typesUse explicit CAST() in SELECT
Singleton INSERT poor perfRemediate: CTAS + drop + rename to consolidate Parquet
fabric-sqlendpoint-execute_query tool not availableMCP server not registered — user must add Fabric SQL Endpoint MCP server
HTTP 429 rate limit exceededWait 60s and retry; consolidate queries into fewer calls
Query timeout (300s)Break into smaller operations; for COPY INTO, check source file sizes
sp_rename on SQLEP failsOnly available on Warehouse, not Lakehouse/Mirrored DB
Deploy drops/recreates tableAvoid ALTER TABLE in DB project; apply manually
Only last result set returnedMCP returns only the final SELECT. Split multi-SELECT batches into separate calls.
Binary columns unreadableColumns with [base64] suffix are base64-encoded. Decode if needed.

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.

Needs: Needs an MCP server

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/sqldw-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 sqldw-cli.zip