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
 SQL Server 2005 Forums
 Transact-SQL (2005)
 Equivalent to Sql Server

Author  Topic 

venkatkrishna
Starting Member

12 Posts

Posted - 2007-05-21 : 03:08:40

Hello the following is the oracle stmt.

can uany one help to get the equivalent sql server stmt.


SELECT dep_id, dep_name,
SYS_CONNECT_BY_PATH(dep_name, '-') 'Dep. Chain'
FROM departments
START WITH dep_id = 0
CONNECT BY PRIOR dep_id = sup_dep_id;

Regards,
Krishna

harsh_athalye
Master Smack Fu Yak Hacker

5581 Posts

Posted - 2007-05-21 : 03:14:56
I believe Sys_connect_By_Path in Oracle is used to retrieve path from root to current node delimited by some character. There is no direct counterpart for this in SQL Server, but you can use CTE feature of SQL Server 2005 to simulate this behavior.

Check this article: [url]http://www.sqlservercentral.com/columnists/fBROUARD/recursivequeriesinsql1999andsqlserver2005.asp[/url]

and,

PLEASE DON'T POST SAME TOPIC AGAIN AND AGAIN UNDER DIFFERENT TOPIC NAME!!

Harsh Athalye
India.
"The IMPOSSIBLE is often UNTRIED"
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2007-05-21 : 03:44:31
Also read about expanding hierarchies in sql server help file

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page
   

- Advertisement -