Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
  1. Home
  2. Database & SysAdmin
  3. Database
  4. A recursive dilema???

A recursive dilema???

Scheduled Pinned Locked Moved Database
databasedata-structureshelptutorialquestion
3 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • A Offline
    A Offline
    AndyBrew70
    wrote on last edited by
    #1

    Hi All Background ---------- I have a database table namely tblSection that stores sections that have parent child relationships e.g. Section 1 | |--Section 2 | |--Section 3 | | | |--Section 4 | |--Section 5 | Section 6 The column structure for this table is: SectionGUID uniqueidentifier PK ParentGUID uniqueidentifier ALLOW NULL Title nvarchar(100) So my root level records are anything where ParentGUID IS NULL and the remaining records can have variable levels of nested children. My Problem ---------- So what would people suggest with regards handling this structure within SQL for example a typical request is to return all sections below a specific node within the hierarchy? Currently I deal with the scenarios I have by extracting all folders into a single System.Data.DataTable object and then traverse the tree within my code which is OK for certain types of process but now I am looking at more number crunching type processes that approach is slow and cumbersome :( Thanks in advance Andy

    P 1 Reply Last reply
    0
    • A AndyBrew70

      Hi All Background ---------- I have a database table namely tblSection that stores sections that have parent child relationships e.g. Section 1 | |--Section 2 | |--Section 3 | | | |--Section 4 | |--Section 5 | Section 6 The column structure for this table is: SectionGUID uniqueidentifier PK ParentGUID uniqueidentifier ALLOW NULL Title nvarchar(100) So my root level records are anything where ParentGUID IS NULL and the remaining records can have variable levels of nested children. My Problem ---------- So what would people suggest with regards handling this structure within SQL for example a typical request is to return all sections below a specific node within the hierarchy? Currently I deal with the scenarios I have by extracting all folders into a single System.Data.DataTable object and then traverse the tree within my code which is OK for certain types of process but now I am looking at more number crunching type processes that approach is slow and cumbersome :( Thanks in advance Andy

      P Offline
      P Offline
      pmarfleet
      wrote on last edited by
      #2

      In SQL Server 2005, you can use Common Table Expressions[^] to perform recursive operations.

      Paul Marfleet "No, his mind is not for rent To any God or government" Tom Sawyer - Rush

      A 1 Reply Last reply
      0
      • P pmarfleet

        In SQL Server 2005, you can use Common Table Expressions[^] to perform recursive operations.

        Paul Marfleet "No, his mind is not for rent To any God or government" Tom Sawyer - Rush

        A Offline
        A Offline
        AndyBrew70
        wrote on last edited by
        #3

        Hi Unfortunately my client is on SQL 2000 so thats a no go, however I found this article during my investigations and with a bit of tweaking works a treat for me :) http://www.vbforums.com/showthread.php?t=366078

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups