Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Umbraco moving multiple documents
--drop table #temp
set nocount on
declare @OldParentId int
declare @ParentId int
declare @Id int
declare @Path nvarchar(150)
select @OldParentId = 1139 -- Set to the existing parent node
select @ParentId = 2457 -- Set to the new parent node
-- First update the parentid column
update umbracoNode set parentid=@ParentId where parentId=@OldParentId
-- Next update all the path columns for the children.
SELECT id,[path] into #temp FROM [umbracoNode] where parentid=@ParentId
while exists(select Id from #temp)
select @Id=Id,@Path=[Path] from #temp
select @Path = REPLACE(@Path,@OldParentId,@ParentId)
update umbracoNode set path=@Path where id=@Id
print cast(@Id as varchar)+': ' +@Path
delete from #temp where Id=@Id
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment