开发者

reparenting hierarchyid values

开发者 https://www.devze.com 2022-12-10 11:49 出处:网络
If I have th开发者_如何转开发e following rows set up in a SQL Server 2008 table: RowHierarchy 11/

If I have th开发者_如何转开发e following rows set up in a SQL Server 2008 table:

Row        Hierarchy
1          1/
2          2/
3          1/1
4          1/2
5          2/1
6          2/2
7          2/1/1

Currently row 5 is parented to row 2. I want to reparent row 5 to row 1, so it would now become 1/3 instead of 2/1. That much I have working so far. I want row 7 (and any other rows down the chain) to remain parented to row 5, which means row 7 should be 1/3/1. What would be some efficient sql to ensure that the hierarchy ids of all children records down the chain get updated as well?


The silence is deafening!

Have you read this? Reordering Data in a Hierarchical Table Using Hierarchical Methods

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号