Hierarchical Query


DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 2 of 2

Thread: Hierarchical Query

  1. #1
    Manohar Guest

    Hierarchical Query

    Hi All,


    We have CONNNECT BY PRIOR and STARTS WITH commands in ORACLE to query for a hierarchical data..

    In MS SQL we don't have any such commands. So how can we achieve this in SQL? If it through stored procedures pls let me know how we can do this in Stored procedures...

    Also pls let me know how to combine results sets of two diffrent select statements that returns same type and number of columns....

    Any help is greatly appreciated.

    TIA

    Rgds
    Manohar

  2. #2
    Simon Sellick Guest

    Re: Hierarchical Query


    Hi Manohar,

    Microsoft give an example of expanding a hierarchy in their books on-line
    included with SQL Server 8. If you have it installed, this link should find
    the example:

    mk:@MSITStore:C:\Program%20Files\Microsoft%20SQL%20Server\80\Tools\Books\acdata.chm::/ac_8_qd_14_5yk3.htm

    To combine two similarly-shaped query results, use UNION or UNION ALL, e.g.

    SELECT a, b FROM c
    UNION
    SELECT d, e FROM f

    Hope this helps,
    Simon Sellick.

    Manohar <manu2679@yahoo.co.uk> wrote:
    >Hi All,
    >
    >
    > We have CONNNECT BY PRIOR and STARTS WITH commands in ORACLE to query

    for a hierarchical
    >data..
    >
    >In MS SQL we don't have any such commands. So how can we achieve this in

    SQL? If it
    >through stored procedures pls let me know how we can do this in Stored procedures...
    >
    >
    >Also pls let me know how to combine results sets of two diffrent select

    statements that
    >returns same type and number of columns....
    >
    >Any help is greatly appreciated.
    >
    >TIA
    >
    >Rgds
    >Manohar



Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center