Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Heirarchical Query
Message
De
18/09/2007 08:12:20
Cetin Basoz
Engineerica Inc.
Izmir, Turquie
 
 
À
18/09/2007 01:21:26
Prashant Dongare
Micropro Software Solutions
Nagpur, Inde
Information générale
Forum:
Microsoft SQL Server
Catégorie:
Syntaxe SQL
Versions des environnements
SQL Server:
SQL Server 2000
Divers
Thread ID:
01255005
Message ID:
01255075
Vues:
13
This message has been marked as the solution to the initial question of the thread.
>Hi all,
>Please can anyone suggest me a counter query in MS SQL for the one in Oracle.
>
>In Oracle I use the following Query to traverse the data from root to the last child.
>
>
>SELECT LPAD(' ',3*LVLCODE) || Name,
>         LVLCODE, PRCODE
> FROM   LEVELMST
> CONNECT BY PRIOR LVLCODE = PRCODE
> START WITH PRCODE = 0
>
>
>To traverse from child to root the query in Oracle is
>
>
>SELECT LPAD(' ',3*LVLCODE) || Name,
>         LVLCODE, PRCODE
> FROM   LEVELMST
> CONNECT BY LVLCODE = PRIOR PRCODE
> START WITH LVLCODE = 17
>
>
>Please help me with these queries.
>Thanks in advance.

In MSSQL 2000 there is no counterpart query. You have to craft your own, check 'expanding hierarchies' in books online.
In MSSQL 2005 you can use recursive CTE, check 'hierarchical queries [SQL Server]' in SQL server 2005 books online.
Cetin
Çetin Basöz

The way to Go
Flutter - For mobile, web and desktop.
World's most advanced open source relational database.
.Net for foxheads - Blog (main)
FoxSharp - Blog (mirror)
Welcome to FoxyClasses

LinqPad - C#,VB,F#,SQL,eSQL ... scratchpad
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform