Code Library

Some simple static analysis queries for Microsoft SQL Server (2005, 2008, 2012)
These queries perform some very basic checks for commonly encountered problems in SQL Server table designs and index implementation. Each query identifies a different type of issue - no rows returned = no problem found.

Proc to generate INSERT or MERGE statements from data in a table. SQL Server.

Proc draws a tabular, fixed-width representation of a query result. SQL Server.

A calendar-generating query using a recursive CTE
A calendar / time dimension template for Microsoft SQL Server 2008, 2012
UK holidays data for the calendar

Password generator (MS SQL Server 2016)

Number table

Text concatenation aggregate
Concatenates rows of text into a single value

Product aggregate
Returns the product of a table of integers. Adapted from a similar idea by Joe Celko

Power set

Alphanumeric key generator
Sequence generator for an incrementing key with alpha and numeric parts

Integer to number base conversion

Reorder the ranking of items in a list

ISO country codes (SQL-92 compatible)

ISO currency codes (SQL-92 compatible)