I recently had some problams emptying the Recycle Bin in Umbraco 4.6.1. I clicked Empty Recycle Bin – but after a few items got removed the progress suddenly stopped showing 201 items remaining. Crap.
No Document exists with Version '00000000-0000-0000-0000-000000000000'
Waiting, restarting IIS and trying to empty the recycle bin again did not help. Time to Google.
I found part of the solution here:
SELECT * FROM umbracoNode, cmsContent -- return nodes
nodeObjectType = 'C66BA18E-EAF3-4CFF-8A22-41B16D66A972' -- that are of type 'Content'
umbracoNode.id NOT IN (SELECT nodeId FROM cmsContent) -- but are not in the 'Content' table
helped me identidy orphan nodes that should be removed.
For each unique umbracoNode.Id in the result (you will get a lot of rows with the same id using the sql above) i ran the sql below to remove these nodes.
DECLARE @TEMPID INT
SET @TEMPID= 1843 -- TYPE IN ID HERE - e.g. 1843
WHERE (nodeId IN (Select id from umbracoNode where parentID = @TEMPID))
WHERE (contentNodeId IN (Select Id from umbracoNode where parentID = @TEMPID))
WHERE (id IN (Select id from umbracoNode where parentID = @TEMPID))
WHERE (ID = @TEMPID)
Then I tried emptying the recycle bin again. Now it deleted 10 more items before it stopped.
I repeated the steps above again – first I ran the select sql to find the new orphan nodes, and then I ran the delete sql’s. I was able to remove 43 more items from the recycle bin this way.
I repeated this procedure until my Recycle Bin was empty (I had to do it 6-7 times or so).
Make sure to backup your database before trying this approach.