• This seems needlessly complex - I just made a UDF that recursively calls itself with more than 1 parameter in my temp database and it works fine?

    Example (and it's a silly one but it does work - it's 1am here!)

    use TempDB
    GO
    create function recurse(
    @p1 int,
    @p2 varchar(10)
    )
    returns varchar(8000)
    AS
    begin
    declare @result varchar(8000)
    if @p1 = 0
      set @result = @p2
    else
      set @result = dbo.recurse(@p1 - 1, @p2 + '.' + cast(@p1 as char(1))) 
    return @result
    end
    GO
    print dbo.recurse(5, 'X')

     

    I can see the benefit of the idea for some reporting purposes where you cannot have the tool work out how the hierarchy relates in client-side code, but if the entire hierarchy is being sent back to the client, you could also just send back the table and let the client sort out the display as well...  Depends on the circumstances I suppose.

    If someone is to implement in their DB/software, try rewriting without the messy string splitting for parameter passing - I don't see why it shouldn't work...

    Cheers