.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Register
 
Win Surprise Gifts!!!
Congratulations!!!


Top 5 Contributors of the Month
MarieAdela
Imran Ghani
Post New Web Links

Need help w/ IsDescendantOf

Posted By:      Posted Date: October 08, 2010    Points: 0   Category :Sql Server
 

Hi,

I'm trying to use IsDescendantOf in a nested SELECT statement. The simple example below works great but in this example @SomeHierarchyID has a single value.

 

DECLARE @SomeHierarchyID hierarchyid
SET @SomeHierarchyID = -- Set some value
SELECT MyItem
FROM myItemsTable AS i
WHERE i.hierarchyIdOfMyItem.IsDescendantOf(@SomeHierarchyID) = 1

 

In my example @SomeHierarchy may have one or many values. So I tried:

SELECT MyItem
FROM myItemsTable AS i
WHERE i.hierarchyIdOfMyItem.IsDescendantOf(SELECT MyHierarchyID FROM SomeHierarchyTable WHERE SomeCondition = 'ConditionMet') = 1

 

This is not working. How can I nest another SELECT statement that will return HierarchyID's for my IsDescendantOf condition?

 


Thanks, Sam


View Complete Post


More Related Resource Links

Categories: 
ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  Silverlight  Others  All   

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend