hierarchyid

Anyone used SQl Server 2008 HierarchialID type to store genealogy data

I have a genealogical database (about sheep actually), that is used by breeders to research genetic information. In each record I store fatherid and motherid. In a seperate table I store complete 'roll up' information so that I can quickly tell the complete family tree of any animal without recursing thru the entire database... Recently...

Type 'Microsoft.SqlServer.Types.SqlHierarchyId' is not supported for identity members.

I'm getting the above exception while trying to read data from a table using Linq2Sql. Does anyone know what's happening here? ...

How can I do a Cascading Delete with the SQL 2008 HierarchyID data type?

I haven't used the HierarchyID much, so I'm a little unsure. If my table has a HierarchyID, how do I perform a cascading delete? (i.e. delete all 'children' when deleting the 'parent') I assume I would have to use a CTE and HierarchyID functions, but not sure how to go about it... ...

Why is there no equivalent for hierarchyid SQL data type?

I understand it that we have to map this type as binary to get to it in the application code. But why isn't there an exact equivalent with all those type methods? How are we supposed to work with in the code? Or we aren't supposed to work with it outside SQL environment at all? EDIT: The question extends to the geography and geometry t...

SQL 2008 HierarchyID with Multiple Root Nodes

I wanted to use the new HierarchyID type in SQL Server 2008 to handle the page relations in a small wiki application. However It would need to have multiple root nodes since every main article/page per account would be a root node. From what I have read the HierarchyID type only allows 1 root node per column is this correct? and is the...

Deploy problem with hierarchyid on automated build only

I am getting the following error during the deploy task of an automated build (Team Foundation Build Server). This deployment may encounter errors during execution because [dbo].[MyTableThatUsesHierarchyId] depends on [sys].[hierarchyid] and [sys].[hierarchyid] does not exist in the target database I can manually deploy ...

Some questions about HierarchyId (SQL Server 2008)

I am a newbie in SQL Server 2008 and just got introduced to HierarchyId's. I am learning from SQL Server 2008 - HIERARCHYID - PART I. So basically I am following the article line by line and while practicing in SSMS I found that for every ChildId some hexadecimal values are generated like 0x,0x58,0x5AC0 etc. My questions are What a...

hierarchyid in SQL Server 2008

I have a hierarchy table with the hierarchy (Schools under different owners). I have another hierarchy table (Departments under different schools) both has diff path. But how to relate both the table to get the Different departments under diff schools and diff owners. how to relate both the tables..... ...

hierarchy concept in SQL Server 2008

i have two hierarchy tables, how to link these two tables using hierarchyid. whether it is possible to link using, deptpath hierarchyid, HID as (previoustablename). deptpath.GetAncestor(1) persisted or any other suggestion.. ...

Error:insert hierarchy values using storedprocedure

I'm getting this error when trying to run a query that inserts results into a table in sql. im passing the table name as parameter,how to give the hierarchy value to the insert statement. here is my code: declare @pathhere hierarchyid select @pathhere=Path from SectionDetails where Sectionid=@sectionid and SectionName=@sectionname and...

SqlMetal, Sql Server 2008 database, Table with HierachyID, dal cs file is created sometimes ?

I have 2 databases with a 2 tables with HierachyID fields. For one database I can get a dal cs file, for the other database I cannot get a dal cs file ? HBus is a database I can get the dal cs for, ... SqlMetal /server:.\SQLSERVER2008 /database:HBus /code:HBusDC.cs /views /functions /sprocs /namespace:HBusDC /context:HBusDataContext ...

How to find ALL descendants using HierarchyID for SQL Server

I need to find all descendants of a category using HierarchyID for SQL Server. I know how to find direct childs but I would like to find childs of childs of child..etc. Is there a way to do this using the hierarchyID. ...

Materialized path pattern VS Hierarchyid

I am reading the SQL server 2008 bible and it says the materialized path pattern is significantly faster then the hierarchyid. Is this really true? How can I make the hierarchyid have equal or better performance. ...

Question about SQL Server HierarchyID depth-first performance

I am trying to implement hierarchyID in a table (dbo.[Message]) containing roughly 50,000 rows (will grow substantially in the future). However it takes 30-40 seconds to retrieve about 25 results. The root node is a filler in order to provide uniqueness, therefor every subsequent row is a child of that dummy row. I need to be able to ...

SQL 2008 HierarchyID - Select X descendants down

How can I query a table which has a column of data type HIERARCHYID and get a list of descendants X levels deep under an employee? Here is the current structure: CREATE TABLE [dbo].[Employees]( [NodeId] [hierarchyid] NOT NULL, [EmployeeId] [int] IDENTITY(1,1) NOT NULL, [FirstName] [varchar](120) NULL, [MiddleInitial] [...

Should I worry about running out of HierarchyIDs?

When you ask for a new HierarchyID between two others, the result gets progressively longer. For example, between 2/5.6 and 2/5.7 there's only 2/5.6.1 and other 4 component paths. The HierarchyID data type is limited to 800 some bytes, so you can't repeat this forever. Then again, integer types are also limited, but it isn't a problem...

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

Given a table with a hierarchyid type column, how do you write a query to return all rows that are ancestors of a specific node? There is an IsDescendantOf() function, which is perfect for getting the children, but there's no corresponding IsAncestorOf() function to return ancestors. (and the absence of a GetAncestors() function seems l...

Ordering in dropdown in MVC

Hi I've a problem with a dropdown in a view in MVC. The option-elements in the dropdown comes from a table and should be ordered by a hierarchyId column. I've made a view which orders correctly, but when I create my entity from the view and use it for the dropdown the ordering is ignored. I found out that hierarchyId datatype is not s...

SQL 2008 HierarchyID support in NHibernate

Searched various NHibernate lists and haven't come up with a definitive answer. The SQL2008 dialect doesn't appear to have support for the HierarchyID data type - new date and time types only. Does anyone have a good implementation or an effective workaround? I'd really like to leverage HierarchyID in a new app of mine. Support for t...

Convert a string to a hierarchyid in C#

Hello guys/girls, I need to be able to convert a string to a hierarchyid in c#.net - I cannot use stored procedures. When I pass in the path (string) the query fails as the path is stored like this '/' instead of / Can I convert it to another type? SqlCommand command = new SqlCommand("INSERT Structure (Path,Description,ParentID) " + ...