[From SQL Server Magazine]
CreateIntegersTable is a multistatement table-valued function written for Microsoft SQL Server 2005. You can use this custom tool to create a numbers table that works around nearly all the limitations that traditional techniques for building these tables usually involve. For example, traditional techniques might themselves involve cursors, loops, or identity columns. The techniques might need temporary tables or actual database tables, which could place expensive demands on database server resources, and the techniques usually lack the flexibility for a developer who needs a different kind of numbers table: one that has starting—and maybe ending—negative values or increment values greater than 1. CreateIntegersTable skirts nearly all these drawbacks.
The article continues at