Skip to content

Instantly share code, notes, and snippets.

@yetanotherchris
Created February 14, 2013 21:38
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save yetanotherchris/4956634 to your computer and use it in GitHub Desktop.
Save yetanotherchris/4956634 to your computer and use it in GitHub Desktop.
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)
begin
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
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment