FIND YOUR NEXT FEW LINES

The snippet library.

Small, practical examples. Search by task or narrow things down below.

125 snippets foundClear filters
SQL ServerText cleanup & matching

Normalize ASCII text to uppercase

SQL Server: UPPER changes character case under the database’s text rules.

SQL Server✓ Tested
SQL ServerSelect & page

Page an ordered result

Skip rows and fetch a bounded page.

OFFSET✓ Tested
SQL ServerRelationships & missing data

Pair employees with their managers

SQL Server: Alias a table twice to represent two different roles in one relationship.

SQL Server✓ Tested
SQL ServerText cleanup & matching

Place missing values after known values portably

SQL Server: A CASE sort key controls NULL placement without relying on engine-specific defaults.

SQL Server✓ Tested
SQL ServerWindow analytics

Rank tied scores with competition gaps

SQL Server: RANK leaves a gap after tied rows, unlike DENSE_RANK.

SQL Server✓ Tested
SQL ServerWindow analytics

Rank tied scores without gaps

SQL Server: DENSE_RANK assigns equal ranks to ties and increments by one for the next distinct score.

SQL Server✓ Tested
SQL ServerSubqueries & ranked selection

Read a page after a known unique key

SQL Server: A keyset predicate avoids scanning and discarding an increasing offset on a suitable index.

SQL Server✓ Tested
SQL ServerJSON & results

Read a scalar JSON property

Extract a named value using a JSON path.

JSON_VALUE✓ Tested
SQL ServerGetting Started

Read named columns from a table

SQL Server: Choose the columns needed and request a deterministic row order.

SQL Server✓ Tested
SQL ServerWindow analytics

Read the last value of the complete partition

SQL Server: Specify an unbounded-following frame so LAST_VALUE does not stop at the current row.

SQL Server✓ Tested
SQL ServerWindow analytics

Read the next row’s value

SQL Server: LEAD reads a later ordered row without a self join and supports a fallback at the end.

SQL Server✓ Tested
SQL ServerGetting Started

Read the smallest and largest values

SQL Server: Use MIN and MAX without sorting and fetching every row.

SQL Server✓ Tested