The conventions the formatter applies. Tab width = 4; indentation and all alignment use real tab characters.
Reserved keywords and built-in functions are lowercase (select, left join, row_number, isnull). Identifiers — schema/table/column names — keep their original case.
Every clause keyword sits in a left column; its operand starts at a fixed tab stop (column 12), forming a vertical river. Keyword and first operand share a line.
select first_expression alias
,second_expression alias
from schema.table t
where 1=1
and t.flag = 1
List items break before the comma, aligned in the river column.
In a select list, aliases line up in a second column (no as). Outlier-long expressions keep a single-tab gap instead of dragging everyone right.
where 1=1Every where opens with 1=1; each real predicate is its own and/or line — trivially commentable and reorderable. Same for multi-condition on.
One blank line separates the select list, from, each join, where, group by… for an airy, scannable layout.
insert intoinsert into base.target (
col_a
,col_b)
select src.col_a col_a
,src.col_b col_b
from ...
update … set … fromAssignments use leading commas with the = signs aligned into their own column; from + joins + where 1=1 follow like a select.
case,(case
when x is null then -1
else 0
end) flag
Short windows stay inline; long ones explode, giving partition by/order by their own mini-river.
,row_number() over (
partition by pa.customer_nrc
,pa.access_point_id
order by pa.promo_start_date asc) sorting_asc
with cte_count as (
select customer_id
,max(temp_order) max_order
from base.history
group by customer_id)
update base
set ...
Sections separated by an indented star-banner block comment.
No space after commas inside argument lists (isnull(x,0), in (5,6)); spaces around comparison/arithmetic operators; . binds tight.
Scope: targets query DML (select / insert…select / update…from / delete, CTEs, case, windows). Procedural wrappers (create/alter procedure, declare, exec, begin…end, use, go) are passed through untouched.