• Take a look at this article by Jeff Moden.

    http://www.sqlservercentral.com/articles/Tally+Table/72993/