I'm trying to migrate from int based primary keys to guid based system, and I'm having trouble with migrating self referenced table
Entity
---------
ID
ParentID
AnotherParentID
When querying the table I'm creating new guid ID
for each row, but how can I set that same guid value for rows that have that ID
as foreign key on ParentID
or AnotherParentID
fields?
SELECT
newid() as ID,
(SELECT e.ID ...?) as ParentID,
(SELECT e.ID ...?) as AnotherParentID,
FROM Entity e