MSSQLTips.com - your daily source for SQL Server tips

Google
 
Web mssqltips.com

ESSENTIALS: Home | Tips | Search | Categories | Top 10 | Products | Authors | Blogs | Forums | Webcasts | Advertise | About
recursive query. - MSSQLTips

MSSQLTips

MSSQLTips.com - your daily source for SQL Server tips
Welcome to MSSQLTips Sign in | Join | Help
in Search

recursive query.

Last post 05-20-2008 6:08 AM by aprato. 1 replies.
Page 1 of 1 (2 items)
Sort Posts: Previous Next
  • 05-19-2008 10:29 PM

    • dipak
    • Top 500 Contributor
    • Joined on 05-20-2008
    • Posts 1

    recursive query.

    i hv 3 field in a table and data.

    currentid  productname  parentid 

    1              sports              0

    2              cricket             1

    3              Ball                 2

    4              Bet                  2

    5              Tennis              1

    6               Racket            5


     

     now i want to write query or store procedure from that i got reasult.

    currentid  productname  parentid 

    1              sports              0

    2              cricket             1

    3              Ball                 1

    4              Bet                 1

    5              Tennis             1

    6               Racket           1


    means all the child find main parent id.

    can any body help me. 

  • 05-20-2008 6:08 AM In reply to

    • aprato
    • Top 10 Contributor
    • Joined on 12-01-2007
    • Greater Boston
    • Posts 239

    Re: recursive query.

    Which version of SQL Server?   

Page 1 of 1 (2 items)