• I won't post the function because that would be too easy for you and you won't learn.:-)

    However, I'll leave you a link to the article that explains how it works and has the code as well. It's a great article and I suggest you to read it, if you don't want to, you still have the option to just download the code.

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

    Luis C.
    General Disclaimer:
    Are you seriously taking the advice and code from someone from the internet without testing it? Do you at least understand it? Or can it easily kill your server?

    How to post data/code on a forum to get the best help: Option 1 / Option 2