The snippet library.
Small, practical examples. Search by task or narrow things down below.
Combine text values with a separator
SQL Server: Use the concatenation operator supported by the selected SQL dialect.
SQL Server✓ Tested
Match a known text prefix
SQL Server: A percent wildcard matches zero or more characters following the prefix.
SQL Server✓ Tested
Measure the length of ordinary text
SQL Server: Use the engine’s text-length function; this ASCII example has no trailing spaces.
SQL Server✓ Tested
Normalize ASCII text to lowercase
SQL Server: LOWER is useful for display normalization; indexed case-insensitive search depends on the database collation and schema.
SQL Server✓ Tested
Normalize ASCII text to uppercase
SQL Server: UPPER changes character case under the database’s text rules.
SQL Server✓ Tested
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
Remove surrounding spaces from text
SQL Server: TRIM removes leading and trailing space characters by default.
SQL Server✓ Tested
Replace a literal substring
SQL Server: REPLACE performs a literal replacement rather than a regular-expression substitution.
SQL Server✓ Tested
Search for a literal LIKE wildcard
SQL Server: Declare an escape character so a percent sign in the pattern is literal.
SQL Server✓ Tested
Treat an empty trimmed value as missing
SQL Server: NULLIF converts an empty string to NULL before a fallback is applied.
SQL Server✓ Tested