Delete All Children of Specified Node ID
/* Delete All Children of Specified Node ID */
Declare @nodeId int
Set @nodeId = -20 /* -20 = Content Recycle Bin, -21 = Media Recycle Bin */
Declare @path varchar(150)
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 into #tmp from umbracoNode where path like @path
select * 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)