SQL Patterns
Common SQL Server query patterns — parameterized and ready to run. Fill in your table details and get production-ready T-SQL for recurring data engineering tasks.
What Are SQL Patterns?
SQL patterns are reusable query templates that solve recurring data engineering problems. Instead of writing the same boilerplate ROW_NUMBER() or recursive CTE from scratch each time, these generators let you fill in your table and column names and get production-ready T-SQL instantly.
Each pattern follows SQL Server best practices — using CTEs for readability, window functions for efficiency, and including a preview step so you can validate results before modifying data.
When to Use Each Pattern
The Date Spine Generator is essential for time-series reporting. If your data has gaps — missing days, weeks, or months where no records exist — a date spine provides the continuous axis you need for accurate aggregation. It generates a complete date series and a LEFT JOIN template that fills gaps with zeros or nulls.
The Deduplication Generator handles one of the most common data quality issues: duplicate rows. It uses ROW_NUMBER() OVER (PARTITION BY ...) to identify duplicates and lets you choose which row to keep based on a tie-breaking column such as a timestamp or ID. The generated query always includes a SELECT preview before any DELETE, so you can verify what will be removed.
