Click here to Skip to main content
15,889,992 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
Ineed to write hierarchyid column from LTR not default state RTL by hierarchyid datatype

for example the default hierarchyid will shown as following :


AccountHierarchy	StringRepresentation	Name
/1000/1100/	           1100/1000	        Current Assets


I need to INSERT data inside hierarchy like StringRepresentation in table above

for example 1100/1000 so that 1100 came from 1000 but in hierarchyid it must written in reverse way /1000/1100/   so please how to solve this because its hard if my tree is so big

What I have tried:

Reverse() function not worked it reversed 1000 to 0001
Posted
Updated 13-May-17 23:06pm
v5
Comments

1 solution

1. Split the string[^] using '/' as separator
2. Reverse the elements[^] in the array...
3. Join the parts[^] using '/' again as separator...
 
Share this answer
 
Comments
Richard Deeming 16-May-17 12:48pm    
There's no behaviour to change, because hierarchyid doesn't store its values as a string. It stores a compact binary representation of the hierarchy.

If you need to change the way it's displayed in the UI, then you'll need to handle that in your UI code.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900