SOT: SQL CTE update

2011-03-29 Thread Jason Durham
I apologize if this is an inappropriate place to ask this question. I'm using a CTE for a recursive query to assemble navigation. In the CTE, I'm creating a column that contains the depth of the navigation. This depth is ultimately inserted into the class of an HTML element. I'm refactoring

Re: SOT: SQL CTE update

2011-03-29 Thread Jason Durham
Nevermind... all I could see were nails. I'll create a temp table for the regular navigation and use that table for breadcrumbs (the depth is accurately created on that query). Jason Durham On Tue, Mar 29, 2011 at 1:44 PM, Jason Durham jqdur...@gmail.com wrote: I apologize if this is an

Re: SOT: SQL CTE update

2011-03-29 Thread Dan G. Switzer, II
Why bother with cursors or temp tables at all and just sort across Depth desc instead of Depth asc? -Dan On Tue, Mar 29, 2011 at 2:59 PM, Jason Durham jqdur...@gmail.com wrote: Nevermind... all I could see were nails. I'll create a temp table for the regular navigation and use that table

Re: SOT: SQL CTE update

2011-03-29 Thread Jason Durham
The in example I posted, I'm calculating the depth in the select statement. The depth is determined by the order in which the row is returned. If I start from a child, the child is returned first (therefore it's 0). If I start from the parent (top level nav), the parent is 0. Consider this...

Re: SOT: SQL CTE update

2011-03-29 Thread Dan G. Switzer, II
Jason, That's why I said to sort the tree in using DESC instead of ASC on the Depth column: - - -*Drivers *(3) - -Software (2) -Support (1) Home (0) If you pull in descending order, you'll know the max depth from the first row, so if it's a matter of using the depth for indenting,