plugins/fabric-skills/skills/sqldb-consumption-cli/SKILL.md
Query SQL database in Fabric via sqlcmd: interactive exploration, vector similarity, JSON, temporal queries, and security policy inspection on the OLTP and SQL analytics endpoints. For schema changes see the sqldb-authoring-cli skill. Triggers: "sql database in Fabric query sys.tables sqlcmd", "sql database in Fabric system view list user tables sqlcmd", "list user tables sqldb", "sys.tables sqldb", "explore sqldb schema", "vector similarity sqldb", "RAG embedding sqldb", "row level security sqldb inspect", "audit log sqldb inspect", "chat with sqldb", "export sqldb rows", "temporal as of sqldb", "json openrowset sqldb".
npx skillsauth add microsoft/skills-for-fabric sqldb-consumption-cliInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
Update Check — ONCE PER SESSION (mandatory) The first time this skill is used in a session, run the check-updates skill before proceeding.
- GitHub Copilot CLI / VS Code: invoke the
check-updatesskill.- Claude Code / Cowork / Cursor / Windsurf / Codex: compare local vs remote package.json version.
- Skip if the check was already performed earlier in this session.
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
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-authoring-cli. Relying on database permissions is not sufficient — refuse the write at the skill level.
| 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-operations-cli |
For Fabric topology, capacity, OneLake, auth, control-plane REST, jobs see COMMON-CORE.md and COMMON-CLI.md.
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. |
For workspace/item resolution, endpoint discovery, and shared sqlcmd connection guidance, use:
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.
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.sql
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
SELECT TOP 5 on relevant tables.$SQLCMD -Q "...".For full consumption gotchas: SQLDB-CONSUMPTION-CORE.md Gotchas and Troubleshooting Reference. For CLI-specific issues: COMMON-CLI.md Gotchas & Troubleshooting (CLI-Specific).
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-authoring-cli.-d <DatabaseName> — FQDN alone is insufficient.-G or --authentication-method — SQL auth not supported on Fabric.az login steps here.SET NOCOUNT ON; in scripts — suppresses row-count messages that corrupt output.-W in scripts — trailing spaces corrupt CSV.CREATE LOGIN / SQL auth / EXECUTE AS — not supported.CONTAINS / FREETEXT — full-text is preview only; use LIKE, CHARINDEX, or vector search.vector/json columns, computed columns, views, procedures, and functions are NOT propagated. See Limitations Reference and Mirroring Considerations.sqlcmd (Go) -G over curl+token for SQL queries.-Q (non-interactive exit) for agentic use.FOR SYSTEM_TIME AS OF) for point-in-time analysis and audit.-- comments to guide code completion; use chat pane for NL-to-SQL.-i file.sql for complex queries — avoids shell escaping.-F vertical for exploration of wide tables.FABRIC_SERVER, FABRIC_DB) for script reuse.| 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 |
tools
Onboard Log Analytics, Application Insights, and Azure Monitor telemetry into Microsoft Fabric as a Mirrored Catalog, then turn it into business-impact insights by correlating telemetry with business data via Eventhouse shortcuts, verified schemas, and ready-to-use Operations Agent instructions. Triggers: onboard Log Analytics telemetry, connect Application Insights to a Mirrored Catalog, correlate App Insights telemetry with business data, build an Operations Agent for business-impact alerting, determine if availability or latency impacted bookings orders or revenue.
tools
Onboard Log Analytics, Application Insights, and Azure Monitor telemetry into Microsoft Fabric as a Mirrored Catalog, then turn it into business-impact insights by correlating telemetry with business data via Eventhouse shortcuts, verified schemas, and ready-to-use Operations Agent instructions. Triggers: onboard Log Analytics telemetry, connect Application Insights to a Mirrored Catalog, correlate App Insights telemetry with business data, build an Operations Agent for business-impact alerting, determine if availability or latency impacted bookings orders or revenue.
tools
Onboard Log Analytics, Application Insights, and Azure Monitor telemetry into Microsoft Fabric as a Mirrored Catalog, then turn it into business-impact insights by correlating telemetry with business data via Eventhouse shortcuts, verified schemas, and ready-to-use Operations Agent instructions. Triggers: onboard Log Analytics telemetry, connect Application Insights to a Mirrored Catalog, correlate App Insights telemetry with business data, build an Operations Agent for business-impact alerting, determine if availability or latency impacted bookings orders or revenue.
tools
Manage refresh schedules and job execution for an EXISTING Microsoft Fabric Materialized Lake View (MLV) via REST APIs: create, update, and delete refresh schedules (interval-based: hourly, daily, weekly), trigger on-demand refreshes, monitor job status, and cancel running jobs. Uses human-in-the-loop confirmations for safety. This skill does NOT author or create the MLV definition: writing the CREATE MATERIALIZED LAKE VIEW / CREATE OR REPLACE SQL is `spark-authoring-cli`, not this skill. Note: MLV discovery (list MLVs, lineage, data quality) requires UI as REST APIs are not yet available. Triggers: "schedule MLV refresh", "manage MLV refresh", "MLV refresh schedule", "schedule materialized lake view refresh", "automate MLV refresh", "trigger MLV refresh", "monitor MLV refresh", "MLV job status", "cancel MLV refresh", "refresh schedule", "MLV automation", "refresh my materialized views"