tags:

views:

218

answers:

1

In SQL server 2008 I have a hierarchical field (hierarchyid). How do I change its value or insert new row when using SQL Server Management Studio "edit rows" command? Is there a textual representation that will be converted to an ID?

Yes, I know I could do it using a query, but I would like to manually enter it as TEXT using the studio editor.

Thanks!

+2  A: 

You can convert a HIERARCHYID to a string using:

hierarchyField.ToString();

You'll get something like '/1/', '/1/1/', '/1/2/' and so forth.

And you can convert such a string representation back to a HIERARCHYID with

SET hierarchyField = hierarchyid::Parse(string)

or

CAST('/2/' AS hierarchyid)

More details on this can be found on Technet

marc_s
yes, but how can you enter that number in the textual table editor in the studio? The only special character that i know is NULL - it automatically gets converted from text to NULL value.
Yurik
I don't think you can enter those values in the interactive table editor - you'll need to use a SQL script to do that.
marc_s