DATE_BUCKET groups timestamps into hourly, weekly, and custom intervals, with an origin that determines where every boundary lands.
COUNT_BIG: Count Rows and Non-NULL Values as bigint
COUNT_BIG helps me name the counting rule before reading the result. Compare rows, supplied values and distinct readings. Then check empty results and the bigint return type.
FORMATMESSAGE: Build a Message Without Raising an Error
FORMATMESSAGE returns formatted text without raising an error. Match placeholders to typed arguments and keep formatting separate from control flow.
RIGHT: Zero Padding Can Remove Significant Digits
RIGHT can make zero padding look correct while quietly removing significant digits. I validate the allowed numeric range before creating a fixed-width label. The suffix expression alone cannot tell whether the input fits.
SQL SERVER – UDF – User Defined Function – Get Number of Days in Month
A simple user defined function that returns the number of days in month for any date, with the leap year rule for February built in.
RADIANS: Cast Integer Degrees Before Conversion
RADIANS changes degrees into radians, but its input type affects the result. The example contrasts integer and float arguments while keeping the original degree values.
GROUPING_ID: Separate Stored NULL Values From ROLLUP Totals
GROUPING_ID helps me distinguish a stored NULL from a subtotal created by ROLLUP. Both can appear in the same column. I keep the grouping bits beside the numbers before adding presentation labels.







