I have been using HierarchyID for the last 2 years in some of my tables for obvious purposes
And I have kept a Column (int) for the last node number for example if I have these rows so the int column for number will be
| HierarchyID | Number |
| ----------- | ------ |
| /1/ | 1 |
| /1/5/ | 5 |
| /1/6/ | 6 |
| /2/ | 2 |
| /2/8/ | 8 |
| /2/9/ | 9 |
| /2/1/10/ | 10 |
I have tried to find a way, to extract the last node value without having to convert ToString() and break the string by the "/" char and going to the last item
Is there a better, maybe built-in, way to do it?
I'm using sql2019
thanks