Created
January 31, 2016 23:21
-
-
Save benmccallum/0d755ab7d066443153f0 to your computer and use it in GitHub Desktop.
Find all Sitecore items under /sitecore/content with $name in a field
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
WITH ItemsWithFullPath (id, name, fullpath) | |
AS | |
( | |
SELECT ID, Name, cast(name as nvarchar(max)) as fullpath | |
FROM [dbo].Items | |
WHERE ParentID = '00000000-0000-0000-0000-000000000000' | |
UNION ALL | |
SELECT i.ID, i.Name, cast((fullpath +'/' + i.name) as nvarchar(max)) as fullpath | |
FROM [dbo].items i | |
INNER JOIN ItemsWithFullPath a on i.ParentID = a.id | |
) | |
SELECT ItemId, Value, Name, FullPath | |
FROM [dbo].[Fields] f | |
INNER JOIN ItemsWithFullPath ips ON ips.ID = f.ItemId | |
WHERE Value = '$name' | |
AND ips.fullpath like 'sitecore/content/%' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment