Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Database > SQL Language
|
SQL Language SQL Language discussions not specific to a particular RDBMS program or vendor.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the SQL Language section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old June 29th, 2005, 02:04 AM
Authorized User
 
Join Date: Oct 2004
Posts: 59
Thanks: 0
Thanked 0 Times in 0 Posts
Default Recursive Stored Procedure

Hi,

Can anyone give me an example for Recursive Stored Procedure using SQL Server 2000.

Ramkumar

A.D.Ramkumar
__________________
Ramkumar A D
 
Old June 29th, 2005, 11:28 AM
Friend of Wrox
 
Join Date: Nov 2003
Posts: 1,348
Thanks: 0
Thanked 5 Times in 5 Posts
Default

What is it that you are trying to do?

 
Old June 30th, 2005, 09:38 AM
Authorized User
 
Join Date: Oct 2004
Posts: 59
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hi,

Actually this is my table data:

EmployeeId EmpName ReportTo
---------- ------------------------- ----------
CEO CEO -
FM FM CEO
HR HR CEO
Oth Oth CEO
PM1 PM1 PMH
PM2 PM2 PMH
PM3 PM3 PMH
PMH PMH CEO
TL11 TL11 PM1
TL12 TL12 PM1
TL21 TL21 PM2
TL22 TL22 PM2
TL23 TL23 PM2
TL31 TL31 PM3
TL32 TL32 PM3
TL33 TL33 PM3
TL34 TL34 PM3

I want to write a recursive Stored Procedure that gets subordinates of a particular given person.

For Eg.
if i give as PMH as input parameter for stored procedure, it should return the following output:

EmployeeId EmpName ReportTo
---------- ------------------------- ----------
PM1 PM1 PMH
PM2 PM2 PMH
PM3 PM3 PMH
TL11 TL11 PM1
TL12 TL12 PM1
TL21 TL21 PM2
TL22 TL22 PM2
TL23 TL23 PM2
TL31 TL31 PM3
TL32 TL32 PM3
TL33 TL33 PM3
TL34 TL34 PM3

Can any body help me in this issue?

Expecting for the reply.

Ramkumar

A.D.Ramkumar





Similar Threads
Thread Thread Starter Forum Replies Last Post
Stored Procedure jezywrap SQL Server ASP 1 January 3rd, 2007 12:29 AM
Stored Procedure Help. midway11 SQL Language 3 November 20th, 2006 06:36 AM
Stored Procedure kk_kumar99 Beginning VB 6 1 October 30th, 2006 12:50 PM
recursive checkbox procedure? pv78 Excel VBA 1 August 16th, 2006 09:54 AM
Stored Procedure rajanikrishna SQL Server 2000 0 July 18th, 2005 05:01 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.