How do you get all ancestors of a node using SQL Server 2008 hierarchyid?

The most commonly used approach would be a recursive Common Table Expression (CTE) WITH Ancestors(Id, [Name], AncestorId) AS ( SELECT Id, [Name], Id.GetAncestor(1) FROM dbo.HierarchyTable WHERE Name=”Joe Blow” — or whatever you need to select that node UNION ALL SELECT ht.Id, ht.[Name], ht.Id.GetAncestor(1) FROM dbo.HierarchyTable ht INNER JOIN Ancestors a ON ht.Id = a.AncestorId ) … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)