Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 Old Forums
 CLOSED - General SQL Server
 Problem abot parent - child relationship table

Author  Topic 

AskSQLTeam
Ask SQLTeam Question

0 Posts

Posted - 2004-02-17 : 08:18:26
abheshek khatri writes "i have a table named project_hierarchy which has these columns and the following data is present in this table :-

employee_sr_no employee_id project_id parent_employee_sr_no
-------------- ----------- ---------- ---------------------
1 2 5 null
2 3 5 1
3 8 5 2
4 6 5 2
5 10 5 2
6 7 5 5
7 11 5 3
8 12 5
10 2 3 null
11 13 3 10
12 3 3 11
13 11 3 10
14 12 3 13
15 9 3 10

My problem is that i want to create a procedure wich excepts employee_id as input parameter and gives all employee_id's who comes under that employee, whose id we have given as an input in procedure.

for example : - if i input employee_id as 2 then , i want the result as employee_sr_no :- 2,3,4,5,6,7 (all levels)

and if that employee comes in anyother project also then i want the same result from that project also.

thanks"

mateenmohd
Constraint Violating Yak Guru

297 Posts

Posted - 2004-02-17 : 23:32:36
if you use sql server 2000 (enterprise manager), you may create relationship by a diagrams.
it option you will see above the database option.



quote:
Originally posted by AskSQLTeam

abheshek khatri writes "i have a table named project_hierarchy which has these columns and the following data is present in this table :-

employee_sr_no employee_id project_id parent_employee_sr_no
-------------- ----------- ---------- ---------------------
1 2 5 null
2 3 5 1
3 8 5 2
4 6 5 2
5 10 5 2
6 7 5 5
7 11 5 3
8 12 5
10 2 3 null
11 13 3 10
12 3 3 11
13 11 3 10
14 12 3 13
15 9 3 10

My problem is that i want to create a procedure wich excepts employee_id as input parameter and gives all employee_id's who comes under that employee, whose id we have given as an input in procedure.

for example : - if i input employee_id as 2 then , i want the result as employee_sr_no :- 2,3,4,5,6,7 (all levels)

and if that employee comes in anyother project also then i want the same result from that project also.

thanks"

Go to Top of Page
   

- Advertisement -