Skip to content

Instantly share code, notes, and snippets.

@garpunkal
Last active October 8, 2019 15:26
Show Gist options
  • Save garpunkal/540dc12ea4f6a65efef69639af2f60c4 to your computer and use it in GitHub Desktop.
Save garpunkal/540dc12ea4f6a65efef69639af2f60c4 to your computer and use it in GitHub Desktop.
Umbraco Delete Documents By DocType
DECLARE @Nodes TABLE (NodeId int)
INSERT INTO @Nodes (NodeId)
SELECT 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 = 'Twitter' OR CT.alias = 'Instagram' OR CT.alias = 'SocialPost'
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 cmsTagRelationship 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 umbracoNode where id in (select NodeId from @Nodes)
DELETE FROM @Nodes
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment