SnippetId
folder
ParentId
item
update item set item.ParentId = folder.SnippetId from dbo.Snippet item inner join dbo.Snippet folder on item.SnippetGroupId = folder.SnippetIndex and item.FolderFlag = 0 and folder.FolderFlag = 1