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 2000 Forums
 SQL Server Development (2000)
 what is the alternative of oracle query like (connect by prior)

Author  Topic 

AskSQLTeam
Ask SQLTeam Question

0 Posts

Posted - 2001-01-17 : 11:01:40
Harish writes "The following query is running in Oracle and output as below.
What will be the alternative in MS-SQL 7.0 to return the same set of output ?

===============
QUERY IN ORACLE
===============

Select grp_code, lpad(' ',level*4) || grp_desc
From f_grouphdr connect by prior grp_code=grp_parent
and Company_Code='MYCOMP_001' and FIN_YEAR='2000-2001'
start with grp_DESC IN
('EXPENDITURE','INCOME','LIABILITIES','ASSETS')
AND Company_Code='MYCOMP_001' and FIN_YEAR='2000-2001'

==========================
SAMPLE OUTPUT FROM ORACLE
==========================


Grp_Code Grp_Name Grp_Parent
=================================================
G000000001 ASSETS ------------------- G000000000
G000000033 --- FIXED ASSETS---------- G000000001
G000000077 ------LAND --------------- G000000033
G000000078 ------BUILDING ----------- G000000033
G000000090 --------FACTORY BLDG.----- G000000078
G000000034 ----INVESTMENT------------ G000000001
G000000002 LIABILITIES--------------- G000000000
G000000005 ---SHARE CAPITAL---------- G000000002
G000000006 ---RESERVER & SURPLUS----- G000000002
G000000011 ------CAPITAL RESERVES---- G000000006
===================================================
   

- Advertisement -