September 6, 2005 at 10:34 pm
Comments posted to this topic are about the content posted at http://www.sqlservercentral.com/columnists/slasham/reportingamenustructureusingarecursiveudf.asp
October 11, 2005 at 9:38 am
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
October 11, 2005 at 4:04 pm
I'll have to tweek my own code as for some reason I was sure I could only have one parameter. Thanks for this.
Viewing 3 posts - 1 through 2 (of 2 total)
You must be logged in to reply to this topic. Login to reply