Last active
August 29, 2015 14:05
-
-
Save eerrecart/dce1b6f96ed3f5c8b0ad to your computer and use it in GitHub Desktop.
Delete Umbraco nodes from recycle bin
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
BEGIN TRANSACTION | |
SET NOCOUNT ON | |
DECLARE @Nodes TABLE (NodeId int) | |
INSERT INTO @Nodes (NodeId) | |
SELECT n.id | |
FROM umbracoNode n | |
WHERE n.path like '%-20%' and id!=-20 | |
DECLARE @nodesCount INT | |
SET @nodesCount = (select count(1) from umbracoNode where id in (select NodeId from @Nodes)) | |
SET NOCOUNT OFF | |
print CAST(@nodesCount AS varchar(50)) + ' nodes to delete' | |
delete from cmsPreviewXml where nodeId in (select NodeId from @Nodes) | |
delete from cmsContentVersion where contentId in (select NodeId from @Nodes) | |
delete from cmsDocument where nodeId in (select NodeId from @Nodes) | |
delete from cmsContentXML where nodeId in (select NodeId from @Nodes) | |
delete from cmsContent where nodeId in (select NodeId from @Nodes) | |
delete from cmsPropertyData where contentNodeId in (select NodeId from @Nodes) | |
delete from umbracoRelation where parentId in (select NodeId from @Nodes) OR childId in (select NodeId from @Nodes) | |
delete from cmsTagRelationship where nodeId in (select NodeId from @Nodes) | |
delete from umbracoNode where id in (select NodeId from @Nodes) | |
DELETE FROM @Nodes | |
IF @@ERROR <> 0 | |
IF @@TRANCOUNT = 1 ROLLBACK TRANSACTION | |
GO | |
IF @@TRANCOUNT = 1 | |
BEGIN | |
PRINT 'nodes deleted' | |
COMMIT TRANSACTION | |
END | |
ELSE | |
BEGIN | |
PRINT 'error deleting nodes, rollback transaciton.' | |
END | |
GO |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment