Skip to content
Advertisement

Cloning tree structure with guid

I am trying to clone tree structure to another table, but the problem is original table has guid as ParentId and Id and new table or table that I want to clone has int as ParentId and Id. I am trying to find the solution so any help is welcomed I tried next as a solution but unfortunately does not work

If it is impossible to do it with a single query then any other solution will be acceptable expect with cursor 🙂 due to a larger amount of data

Here is the Sample so the output of a query(SP) should be tree structure with int-s as Id, ParentId

Advertisement

Answer

How about this:

or you can simply use checksum() function:

Please note, with the second approach you might get collisions.

User contributions licensed under: CC BY-SA
1 People found this is helpful
Advertisement