Last active
August 29, 2015 14:01
-
-
Save timgaunt/f67acfe1a1c91152c607 to your computer and use it in GitHub Desktop.
Delete Umbraco nodes by DocumentType
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 TRAN | |
DECLARE @Nodes TABLE (NodeId int) | |
INSERT INTO @Nodes (NodeId) | |
SELECT top 1000 n.id | |
FROM cmsContent C | |
INNER JOIN cmsContentType CT ON C.contentType = CT.nodeId | |
INNER JOIN umbracoNode N ON C.nodeId = N.id | |
WHERE CT.alias = '[Your Document Type Alias Here]' | |
-- Alternatively delete from the recylebin | |
-- from umbracoNode n where n.path like '%-20%' and id!=-20 | |
select id, [text] from umbracoNode where id in (select NodeId from @Nodes) | |
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) | |
delete from umbracoRelation where 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 | |
ROLLBACK TRAN |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment