sqlserver-patterns

Provides T-SQL and SQL Server best practices for queries, indexing, and stored procedures.

1|Updated Mar 4, 2026
One-click install
npx skills add https://github.com/flatrick/mdt --skill sqlserver-patterns-flatrick
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: sqlserver-patterns
Source: https://github.com/flatrick/mdt/tree/main/skills/sqlserver-patterns
Command: npx skills add https://github.com/flatrick/mdt --skill sqlserver-patterns-flatrick

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve?

This Skill provides a comprehensive guide to writing efficient, secure, and maintainable T-SQL code for SQL Server and Azure SQL Database, helping developers avoid common pitfalls and optimize database performance.

Core Features & Use Cases

  • Best Practices: Covers essential T-SQL patterns like parameterized queries, set-based operations, and proper transaction handling.
  • Performance Tuning: Offers guidance on indexing strategies, query plan analysis, and temporal tables.
  • Schema Design: Provides recommendations for robust and scalable database schema design.
  • Use Case: When writing a complex stored procedure, consult this Skill to ensure you're using parameterized queries, appropriate isolation levels, and efficient indexing for optimal performance and security.

Quick Start

Review the best practices for writing T-SQL queries and stored procedures.

Frequently Asked Questions about sqlserver-patterns

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
What are the best practices for T-SQL query optimization in SQL Server?

T-SQL query optimization best practices include using set-based operations, parameterized queries, and proper indexing strategies. This Skill provides guidance on query plan analysis and window functions to help avoid common performance pitfalls in SQL Server and Azure SQL Database.

How do I write efficient stored procedures in SQL Server using T-SQL?

Writing efficient stored procedures requires appropriate isolation levels, proper transaction handling, and parameterized queries. This Skill offers T-SQL patterns for error handling and schema design to ensure your stored procedures are secure, maintainable, and performant.

Does this T-SQL guidance cover Azure SQL Database and SQL Server 2016+?

Yes, this T-SQL guidance covers SQL Server 2016+ and Azure SQL Database. It includes specific best practices for features like temporal tables, CTEs, and window functions across both platforms to ensure portability and optimal performance.

What is the best way to design a scalable SQL Server database schema?

The best way to design a scalable SQL Server database schema is to follow robust design patterns and proper indexing strategies. This Skill provides recommendations for schema design, portability considerations between T-SQL and ANSI SQL, and temporal table usage.

How do I handle transactions and isolation levels in T-SQL?

Handling transactions in T-SQL requires proper transaction handling and appropriate isolation levels to maintain data integrity. This Skill outlines best practices for transaction management and error handling patterns to prevent concurrency issues.

When should I use CTEs and window functions in SQL Server?

You should use CTEs and window functions in SQL Server to write efficient, readable set-based operations instead of cursors. This Skill provides best practices for applying these features to optimize query performance and complex data analysis.