Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save eerrecart/d1393ee1eb166a09883b to your computer and use it in GitHub Desktop.
Save eerrecart/d1393ee1eb166a09883b to your computer and use it in GitHub Desktop.
Umbraco - Delete All Children of Specified Node ID
/* Delete All Children of Specified Node ID */
Declare @nodeId int
Set @nodeId = 18904 /* -20 = Content Recycle Bin, -21 = Media Recycle Bin */
Declare @path varchar(500)
Set @path = (Select top 1 path from umbracoNode Where id = @nodeId)
/* If you want to delete the item as well, remove the comma from the following line. */
Set @path = @path + ',%'
IF OBJECT_ID('tempdb..#tmp') IS NOT NULL DROP TABLE #tmp
select id, [text] into #tmp from umbracoNode where path like @path
select count(1) from #tmp
--delete from cmsPreviewXml where versionID in (select versionid from cmsContentVersion where ContentId in (select nodeId from cmsContent where nodeId in (Select id from #tmp)))
--delete from cmsContentVersion where ContentId in (select nodeid from cmsContent where nodeId in (Select id from #tmp))
--delete from cmsPropertyData where contentNodeId in (Select id from #tmp)
--delete from cmsContentXML where nodeId in (select nodeid from cmsContent where nodeId in (Select id from #tmp))
--delete from cmsDocument where nodeId in (Select id from #tmp)
--delete from cmsContent where nodeId in (Select id from #tmp)
--delete from cmsTagRelationship where nodeId in (select id from umbracoNode where path like @path)
--delete from umbracoNode where id in (Select id from #tmp)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment