Execute read-only T-SQL queries against Fabric Data Warehouse, Lakehouse SQL Endpoints, and Mirrored Databases via CLI. Default skill for any lakehouse data query (row counts, SELECT, filtering, aggregation) unless the user explicitly requests PySpark or Spark DataFrames. Use when the user wants to: (1) query warehouse/lakehouse data, (2) count rows or explore lakehouse tables, (3) discover schemas/columns, (4) generate T-SQL scripts, (5) monitor SQL performance, (6) export results to CSV/JSON. Triggers: "warehouse", "SQL query", "T-SQL", "query warehouse", "show warehouse tables", "show lakehouse tables", "query lakehouse", "lakehouse table", "how many rows", "count rows", "SQL endpoint", "describe warehouse schema", "generate T-SQL script", "warehouse performance", "export SQL data", "connect to warehouse", "lakehouse data", "explore lakehouse".
microsoft277 스타2026. 3. 9.
직업
카테고리
SQL 데이터베이스
스킬 내용
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-updates skill.
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
# Interactive session (Entra login via browser if needed)
sqlcmd -S "<endpoint>.datawarehouse.fabric.microsoft.com" -d "<DatabaseName>" -G
# Non-interactive one-shot query
sqlcmd -S "<endpoint>.datawarehouse.fabric.microsoft.com" -d "<DatabaseName>" -G \
-Q "SELECT TOP 10 * FROM dbo.FactSales"
# Explicit ActiveDirectoryDefault (uses az login session)
sqlcmd -S "<endpoint>.datawarehouse.fabric.microsoft.com" -d "<DatabaseName>" \
--authentication-method ActiveDirectoryDefault \
-Q "SELECT TOP 10 * FROM dbo.FactSales"
# Service principal (CI/CD)
SQLCMDPASSWORD="<clientSecret>" \
sqlcmd -S "<endpoint>.datawarehouse.fabric.microsoft.com" -d "<DatabaseName>" \
--authentication-method ActiveDirectoryServicePrincipal \
-U "<appId>" \
-Q "SELECT COUNT(*) FROM dbo.FactSales"
Reusable Connection Variables
# Set once at script top
FABRIC_SERVER="<endpoint>.datawarehouse.fabric.microsoft.com"
FABRIC_DB="<DatabaseName>"
SQLCMD="sqlcmd -S $FABRIC_SERVER -d $FABRIC_DB -G"
# Use throughout
$SQLCMD -Q "SELECT TOP 5 * FROM dbo.DimProduct"
$SQLCMD -i myscript.sql
PowerShell / Windows CMD
# PowerShell
$s = "<endpoint>.datawarehouse.fabric.microsoft.com"; $db = "<DatabaseName>"
sqlcmd -S $s -d $db -G -Q "SELECT TOP 10 * FROM dbo.FactSales"
# CMD: use set S=... and %S% / %DB% instead of $variables
Agentic Exploration ("Chat With My Data")
Schema Discovery Sequence
Run these in order to understand what's in the endpoint. See references/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 and views
$SQLCMD -Q "SELECT table_schema, table_name, table_type FROM information_schema.tables ORDER BY table_schema, table_name" -W
# 3. Columns for a table
$SQLCMD -Q "SELECT column_name, data_type, character_maximum_length, is_nullable FROM information_schema.columns WHERE table_schema='dbo' AND table_name='FactSales' ORDER BY ordinal_position" -W
# 4. Preview rows
$SQLCMD -Q "SELECT TOP 5 * FROM dbo.FactSales" -W
# 5. 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
# 6. Programmability objects (views, functions, procedures)
$SQLCMD -Q "SELECT name, type_desc FROM sys.objects WHERE type IN ('V','FN','IF','P','TF') ORDER BY type_desc, name" -W
Agentic Workflow
Discover → Run Steps 1–3 to understand available tables/columns.
Present → Show results or generate a reusable script (Script Generation section).
Gotchas, Rules, Troubleshooting
For full T-SQL/platform gotchas: SQLDW-CONSUMPTION-CORE.md Gotchas and Troubleshooting Reference and COMMON-CLI.md Gotchas & Troubleshooting (CLI-Specific).
MUST DO
Always -d <DatabaseName> — FQDN alone is insufficient.
Always -G or --authentication-method — SQL auth not supported on Fabric.
az login first — ActiveDirectoryDefault uses az session. No session → cryptic failure.
SET NOCOUNT ON; in scripts — suppresses row-count messages that corrupt output.
Label queries with OPTION (LABEL = 'AGENTCLI_...') for Query Insights tracing.
AVOID
ODBC sqlcmd (/opt/mssql-tools/bin/sqlcmd) — requires ODBC driver. Use Go version.
Omitting -W in scripts — trailing spaces corrupt CSV.
DML on SQLEP — Lakehouse/Mirrored DB endpoints are read-only. DML only on Warehouse.
MARS — not supported. Remove MultipleActiveResultSets from connection strings.
Hardcoded FQDNs — discover via REST API (Discover the SQL Endpoint FQDN).
PREFER
sqlcmd (Go) -G over curl+token for SQL queries.
-Q (non-interactive exit) for agentic use.
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.
az rest for Fabric REST API — use sqlcmd only for T-SQL.
TROUBLESHOOTING
Symptom
Cause
Fix
Login failed for user '<token-identified principal>'
Wrong DB name or no access
Verify -d matches item name exactly (case-sensitive)