Let's say I have a hierarchyid column in SQL Server (2008 R2). Let's say I have the following nodes already in the table:
/1/
/1/1/
/1/2/
I'd like to create an insert statement that inserts between '/1/1/' and '/1/2/', creating node '/1/1.1/'. However, I don't want to hardcode '/1/1.1/'. I want to base the insert statement on knowing '/1/1/' and '/1/2/'. This will be a stored proc so it is okay if some T-SQL is necessary before the insert statement.
Copyright Notice:Content Author:「RationalGeek」,Reproduced under the CC 4.0 BY-SA copyright license with a link to the original source and this disclaimer.
Link to original article:https://stackoverflow.com/questions/15432635/sql-server-hierarchyid-insert-new-node-between-two-existing-sibling-nodes