Last active
September 12, 2018 15:02
-
-
Save zlypher/fdb11bdc3e9295fdf813a4c8b9aac5ff to your computer and use it in GitHub Desktop.
Umbraco: Find Document Types
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
-- Find all umbraco nodes and the document type by the given document type id | |
-- Replace "XX_DOC_TYPE_ID_XX" with the document type id you want to look for | |
SELECT | |
ct.[nodeId] as 'DocumentType ID', | |
ct.[alias] as 'DocumentType Name', | |
un.[id] as 'Node ID', | |
un.[text] as 'Node Name', | |
un.* | |
FROM [dbo].[cmsContentType] ct | |
LEFT JOIN [dbo].[cmsContent] co | |
ON co.[contentType] = ct.[nodeId] | |
LEFT JOIN [dbo].[umbracoNode] un | |
ON un.[id] = co.[nodeId] | |
WHERE | |
ct.[nodeId] = XX_DOC_TYPE_ID_XX |
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
-- Find all document types, that are | |
-- a) unused | |
-- b) only used on thrashed nodes | |
SELECT | |
ct.[nodeId] as 'DocumentType ID', | |
ct.[alias] as 'DocumentType Name', | |
un.[id] as 'Node ID', | |
un.[text] as 'Node Name' | |
FROM [dbo].[cmsContentType] ct | |
LEFT JOIN [dbo].[cmsContent] co | |
ON co.[contentType] = ct.[nodeId] | |
LEFT JOIN [dbo].[umbracoNode] un | |
ON un.[id] = co.[nodeId] | |
WHERE | |
ct.[nodeId] NOT IN ( | |
SELECT DISTINCT | |
ct.[nodeId] | |
FROM [dbo].[cmsContentType] ct | |
LEFT JOIN [dbo].[cmsContent] co | |
ON co.[contentType] = ct.[nodeId] | |
LEFT JOIN [dbo].[umbracoNode] un | |
ON un.[id] = co.[nodeId] | |
WHERE | |
un.[trashed] = 0 | |
) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment