• Have a look at this too, by Itzik Ben-Gan:

    http://www.sqlmag.com/article/sql-server/virtual-auxiliary-table-of-numbers

    Should perform better than a recursive CTE.