sql-server-best-practiceslisted
Install: claude install-skill MaskedControl/skills
# SQL Server Best Practices
This skill covers both on-premises SQL Server (2016+) and Azure SQL Database / Managed Instance.
When differences exist between the two, they are called out in the relevant section.
## How to Use This Skill
Identify which domain(s) the user's request falls into, then read the corresponding reference file(s)
before responding. For requests that touch multiple domains (e.g., "review this stored proc and its
indexes"), read all relevant files.
| Domain | When to use | Reference file |
|--------|-------------|----------------|
| T-SQL & query patterns | Writing queries, stored procs, functions, CTEs, cursors, error handling | `references/query-patterns.md` |
| Indexing strategy | Index design, fragmentation, missing/duplicate indexes, query plan issues | `references/indexing.md` |
| Schema & data modeling | Table design, data types, naming conventions, constraints, relationships | `references/schema-design.md` |
| Security | Permissions, least privilege, dynamic SQL injection, encryption, auditing | `references/security.md` |
| Maintenance & monitoring | Health checks, index rebuild, statistics, backups, CHECKDB | `references/maintenance.md` |
## Quick Principles (always apply)
These apply regardless of domain — internalize them before reading any reference file:
1. **Correctness first.** A fast query that returns wrong results is worse than a slow correct one.
2. **Set-based over row-by-row.** SQL Server is optimized for set operations; cursors