Hey I'm Lee. My blog was put up to house my strange thoughts, ramblings, nuggets of information I can refer back to and document my learning curves on new dev stuff and fitness regimes.

All thoughts and comments on here are my own, and in no way reflect my employer - I also take no responsibility for spelling, grammar, terminology, accuracy of facts etc... So read at your own risk!

Mass Delete Over 1K nodes From Recycle Bin In 4.7

I just had a problem where I had just over 1K of nodes which had accumulated in my Recycle Bin while developing a large new umbraco site.  But every time I clicked empty Recycle Bin the pop up would open and it would say deleting nodes, but it wouldn't do anything.

After a bit of searching around I found a great SQL script from the Umbraco legend Doug Robar for deleting all nodes in the Recylce bin for an older version of Umbraco, with a bit of tinkering I have updated it to work with v4.7.

*** USE THIS AT YOUR OWN RISK!! ***

It has worked fine for me, but back up your DB before you do it.

-- Uncomment below to verify the number of nodes returned is the 
-- same as the number of nodes that is in the Recycle Bin
-- select * from umbracoNode where path like '%-20%' and id!=-20

-- Delete all 'related' nodes and table contents...
delete from cmsPreviewXml where nodeId in (select id from umbracoNode where path like '%-20%' and id!=-20)
delete from cmsContentVersion where ContentId in (select id from umbracoNode where path like '%-20%' and id!=-20)
delete from cmsContent where nodeId in (select id from umbracoNode where path like '%-20%' and id!=-20)
delete from cmsContentXML where nodeId in (select id from umbracoNode where path like '%-20%' and id!=-20)
delete from cmsDocument where nodeId in (select id from umbracoNode where path like '%-20%' and id!=-20)
delete from cmsPropertyData where contentNodeId in (select id from umbracoNode where path like '%-20%' and id!=-20)
-- delete the XML nodes....
delete from umbracoNode where path like '%-20%' and id!=-20
Back to top