-
August 4th, 2011, 03:12 AM
#1
High Performance Hierarchies in SQL Server
i am using CTE, but failed to use with SP
;WITH EmpCTE AS
(
SELECT a.EmployeeId,CAST ('' AS VARCHAR(500)) AS Reporting_Heads
FROM EmpTable a
WHERE
a.BossId IS NULL
UNION ALL
SELECT E.EmployeeId,
CAST (Ec.reporting_Heads + ',' + CAST(Ec.EmployeeId AS Varchar(200)) AS VARCHAR(500)) AS Reporting_Heads
FROM EmpCTE Ec
INNER JOIN
EmpTable E
ON
E.BossId = Ec.EmployeeId
)
SELECT Reporting_Heads FROM EmpCTE WHERE EmpCTE.EmployeeId = 100004
I am having emp table.
I want to find out Emp BossID,
I want to pass EmployeeId Through Store Procedure, which i will be using in C#.net and want result like below mention screen,
please refer below mention image url
http://www.imgplace.com/viewimg535/1452/69cte.jpg
Tags for this Thread
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|