• Hey Jano, thanks for writing the article. Unfortunately, I think some of the code is formatted incorrectly, as I could not see it in the article.

    Also, your solution works, but is limited to the number of values that you set in the function (9 in this case).

    See this article on Tally tables for an alternate solution by Jeff Moden that will parse through an unlimited number of values without needing to loop:

    http://www.sqlservercentral.com/articles/TSQL/62867/

    Thanks again for your efforts, keep writing! 🙂

    Jon

    ---------------------------------------------------------
    How best to post your question[/url]
    How to post performance problems[/url]
    Tally Table:What it is and how it replaces a loop[/url]

    "stewsterl 80804 (10/16/2009)I guess when you stop and try to understand the solution provided you not only learn, but save yourself some headaches when you need to make any slight changes."