SQL Store Procedure

Results 1 to 2 of 2

Thread: SQL Store Procedure

  1. #1
    Join Date
    Dec 1969

    Default SQL Store Procedure

    I want to have a SP return a record set but i want the record set to be a combination of 2 ( or more) record sets. Basicaly I have a table that looks like this<BR><BR>ID<BR>NAME<BR>ParentID<BR><BR>Heres some Data<BR>ID Name ParentId<BR><BR>1 Jeremy 0<BR>2 Sue 0<BR>3 Beth 1<BR>4 Sam 1<BR>5 Timmy 3 <BR><BR>so I want the SP to return a record set that looks like this<BR><BR>1 Jeremy 0<BR>3 Beth 1<BR>5 Timmy 3 <BR>4 Sam 1<BR>2 Sue 0<BR><BR>So I can then make it look like this<BR><BR>1 Jeremy 0<BR> 3 Beth 1<BR> 5 Timmy 3 <BR> 4 Sam 1<BR>2 Sue 0<BR><BR>So the SP needs to get all the records that parent id = 0 then for each one, and each new one, insert the records that are that records child.<BR><BR>I currently have this as a ASP Sub, that calles it self and prints the stuff out to the screen, but there has to be a better way, and i need this for other projects..... ANy help is greatly appreciated..

  2. #2
    Join Date
    Dec 1969

    Default Look for dozens of posts...

    ...on this topic in various forums here. Mostly in DB forum.<BR><BR>If you don&#039;t change your DB design, then your SP will have to do the same crappy recursion that your VBS code does. It will be some faster, but it&#039;s still at terrible solution. Recursion with DBs bites. Period.<BR><BR>[Except that SQL Server Yukon version--in Beta now--has special support for this. But that doesn&#039;t help you now.]<BR><BR>SQLTeam.com has had a couple of articles on this in the past and has a couple of nice long discussions in the forums, as well.<BR><BR>Oh, heck...I searched for my own old posts.<BR><BR>Here:<BR>http://www.aspmessageboard.com/forum/showMessage.asp?F=21&M=670136&P=1

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts