﻿<?xml version='1.0' encoding='UTF-8'?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/"><channel><title>SQLServerCentral / Discuss Content Posted by Stephen Lasham / Article Discussions / Article Discussions by Author  / Reporting a menu structure using a recursive UDF / Latest Posts</title><generator>InstantForum.NET v2.9.0</generator><description>SQLServerCentral</description><link>http://www.sqlservercentral.com/Forums/</link><webMaster>notifications@sqlservercentral.com</webMaster><lastBuildDate>Wed, 22 May 2013 05:20:42 GMT</lastBuildDate><ttl>20</ttl><item><title>RE: Reporting a menu structure using a recursive UDF</title><link>http://www.sqlservercentral.com/Forums/Topic217493-176-1.aspx</link><description>I'll have to tweek my own code as for some reason I was sure I could only have one parameter.  Thanks for this.</description><pubDate>Tue, 11 Oct 2005 16:04:00 GMT</pubDate><dc:creator>Lashams</dc:creator></item><item><title>RE: Reporting a menu structure using a recursive UDF</title><link>http://www.sqlservercentral.com/Forums/Topic217493-176-1.aspx</link><description>&lt;P&gt;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?&lt;/P&gt;&lt;P&gt;Example (and it's a silly one but it does work - it's 1am here!)&lt;/P&gt;&lt;PRE&gt;use TempDBGOcreate function recurse(@p1 int,@p2 varchar(10))returns varchar(8000)ASbegin&lt;/PRE&gt;&lt;PRE&gt;declare @result varchar(8000)&lt;/PRE&gt;&lt;PRE&gt;if @p1 = 0  set @result = @p2else  set @result = dbo.recurse(@p1 - 1, @p2 + '.' + cast(@p1 as char(1))) &lt;/PRE&gt;&lt;PRE&gt;return @resultendGO&lt;/PRE&gt;&lt;PRE&gt;print dbo.recurse(5, 'X')&lt;/PRE&gt;&lt;P&gt; &lt;/P&gt;&lt;P&gt;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.&lt;/P&gt;&lt;P&gt;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...&lt;/P&gt;&lt;P&gt;Cheers   &lt;img src='images/emotions/cool.gif' height='20' width='20' border='0' title='Cool' align='absmiddle'&gt;&lt;/P&gt;</description><pubDate>Tue, 11 Oct 2005 09:38:00 GMT</pubDate><dc:creator>Ian Yates</dc:creator></item><item><title>Reporting a menu structure using a recursive UDF</title><link>http://www.sqlservercentral.com/Forums/Topic217493-176-1.aspx</link><description>Comments posted to this topic are about the content posted at &lt;A HREF="http://www.sqlservercentral.com/columnists/slasham/reportingamenustructureusingarecursiveudf.asp"&gt;http://www.sqlservercentral.com/columnists/slasham/reportingamenustructureusingarecursiveudf.asp&lt;/A&gt;</description><pubDate>Tue, 06 Sep 2005 22:34:00 GMT</pubDate><dc:creator>Lashams</dc:creator></item></channel></rss>