Agent skill · data analytics · aiskillstore
sql-expert
Write, optimize, and debug T-SQL queries for Microsoft SQL Server. Covers CTEs, window functions, PIVOT, MERGE, APPLY operators, execution plan analysis, indexing strategies, and stored procedures. Use when working with SQL Server, T-SQL scripts, .sql files, stored procedures, query optimization, or database performance tuning.
Why this skill is useful
Provides advanced T-SQL optimization techniques and specific query patterns that the AI wouldn't reliably generate on its own.
What it needs
About 1k tokens when loaded. Last updated 2026-08-07. 405 stars on the source repository.
What this skill does
SQL Expert Expert assistance for Microsoft SQL Server and T-SQL development. Instructions When helping with T-SQL: 1. Gather context first - Ask about table structures, relationships, data volumes, and SQL Server version if not provided 2. Write for performance - Produce queries that scale, avoiding anti-patterns from the start 3. Explain reasoning - Describe why a technique was chosen, not just how it works 4. Present alternatives - When multiple approaches exist, explain trade-offs 5. Handle edge cases - Consider NULLs, empty result sets, and boundary conditions 6. Note version requirements - Flag features that require specific SQL Server versions Core Capabilities Query optimization: Execution plan analysis, index recommendations, eliminating anti-patterns Advanced techniques: CTEs (recursive/non-recursive), window functions, PIVOT/UNPIVOT, MERGE, CROSS/OUTER APPLY Data processing: JSON/XML handling, temporal tables, dynamic SQL Stored procedures: Error handling with TRY...CATCH, transaction management, table-valued parameters Quick Reference Anti-Patterns to Catch Error Handling Template Version-Specific Features Feature Version --------- --------- STRINGAGG, TRIM 2017+ JSON functions, STRINGSPLIT 2016+ GENERATESERIES, GREATEST/LEAST 2022+ Additional References references/patterns.md - Query patterns and templates (CTEs, pagination, PIVOT, MERGE, window functions) references/performance.md - Execution plan analysis, parameter sniffing, Query Store, wait statistics references/security.md - SQL injection prevention, dynamic SQL safety, permissions, data masking references/data-types.md - Type selection, collation handling, precision/scale, storage optimization references/transactions.md - Isolation levels, deadlock prevention, distributed transactions, sagas
How to use it
Reference it in AdaL, Claude Code, Cursor or any coding agent — nothing to install:
@skills aiskillstore/sql-expert--c2b573