• Like I asked before, can we please get some DDL and sample data? This would really make things a lot easier. Could you perhaps give a more detailed explanation of your goals as well? We now know you want to do this inside an udf, which is fine (although in 2005 you only have access to scalar functions), but it gives us a bit more to work with

    P.s. You should of really posted this in the 2005 forum then, if you're running 2005. There's a lot of differences between 2012 and 2005.

    Thom~

    Excuse my typos and sometimes awful grammar. My fingers work faster than my brain does.
    Larnu.uk