Link to home
Start Free TrialLog in
Avatar of JeffDrummond
JeffDrummond

asked on

Get top level ParentId for a menu

My procedure takes a string parameter which represents a subpage item in a menu.
From that string I need to return the top level parent menu item, which will have
a ParentCategoryId of 0 (zero).

This is an example of the table:

CatId         Page name               ParentCategoryId
------         -------------               --------------------
2     Home Page     0
8     001-About Us     0
13     002-Our Neighborhoods     0
14     003-Featured Buildings     0
15     004-For Buyers     0
16     005-Our Listings     0
17     006-Testimonials     0
18     007-Our Team     0
19     008-RE News     0
20     009-For Investors     0
21     001-Area Information     13
22     002-Links     13
23     001-Services     15
24     002-Buyer Agency     15
25     003-Finance Center     15
26     001-Lenders     25
27     002-Mortgage Calculator / Tax Estimator     25
28     003-Dream Home Request     25
29     001-Due Diligence     20
30     002-Investment Types     20
31     003-Commercial Marketing Plan     20
9     001-Mission     8
10     002-Management     8
11     003-Careers     8
12     004-Contact Us     8

If the input parameter is "Dream Home Request", the ParentCategoryId = 25, or Finance Center.
The ParentCategoryId of Finance Center is 15, or For Buyers.
The ParentCategoryId of For Buyers is 0, so I need to return 15, because that is the top level
of the menu.

Can you help me write this stored procedure?

Thanks!
ASKER CERTIFIED SOLUTION
Avatar of Guy Hengel [angelIII / a3]
Guy Hengel [angelIII / a3]
Flag of Luxembourg image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of JeffDrummond
JeffDrummond

ASKER

Thanks angelIII.  Works perfectly!