What a NOT NULL constraint does and two ways to add one: when the table is created, or after the table is created. My example covers both.
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.
GROUP BY Done Right
GROUP BY Done Right separates row filters from group filters, handles NULL groups, and avoids totals inflated by careless joins.
TRY_CONVERT Integer Validation: Check the Target Type
TRY_CONVERT integer validation starts with the destination type and a separate input policy. This example compares blank, signed, decimal and overflowing text without writing data.
CONCAT_WS: Keep NULL and Empty Strings Separate
CONCAT_WS joins values with a separator, but NULL and empty strings have different effects. These examples keep the original fields beside the combined text and byte length.
SQL SERVER – Explanation and Comparison of NULLIF and ISNULL
NULLIF returns NULL when two expressions are equal and the first one when they are not. Here is how it compares with ISNULL and the matching CASE expression.
SQL SERVER – LEN and DATALENGTH of NULL Simple Example
A common mistake is checking LEN(@var) = 0 for a NULL value. LEN and DATALENGTH of NULL both return NULL, not zero, as this simple example shows.







