Microsoft SQL Server
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
 
User Name:
Password:
Remember me
Go Back   ASP Free ForumsDatabaseMicrosoft SQL Server

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread ASP Free Forums Sponsor:
  #1  
Old March 31st, 2004, 02:54 AM
Kris_Vanherck's Avatar
Kris_Vanherck Kris_Vanherck is offline
Contributing User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Feb 2004
Location: Belgium, Antwerp
Posts: 177 Kris_Vanherck User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 24 sec
Reputation Power: 5
Question SQL Recursie view or stored procedure

I have a table with a recursive parent-child relation: Parent_ID refers to Line_ID

example of how that may look:
Line_ID . Parent_ID
------------------
1 . . . . . null -- higest item (no parent)
2 . . . . . 1
3 . . . . . 1
4 . . . . . 2
5 . . . . . 3
6 . . . . . 3
7 . . . . . 5
8 . . . . . 5
9 . . . . . 8
10 . . . . null

What i need is the following fucntion/view/..:
INPUT = any Line_ID
OUTPUT = table with ALL its LOWEST children (a Line_ID that has no Parent_ID refering to it)

example:
. . 1 . . . . . . . 10
|----|
2 . . 3
| . |---|
4 . 5 . .6
. .|-|
. .7 8
. . . |
. . . 9

1 would give 4, 6, 7, 9
2 would give 4
3 would give 6, 7, 9
4 would give null
5 would give 7, 9

Last edited by Kris_Vanherck : March 31st, 2004 at 02:56 AM. Reason: formating

Reply With Quote
Reply

Viewing: ASP Free ForumsDatabaseMicrosoft SQL Server > SQL Recursie view or stored procedure


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 4 hosted by Hostway
Stay green...Green IT