Last active
May 9, 2022 15:24
-
-
Save asontu/0feb1c592a42dd0cea34bbf0c9eee806 to your computer and use it in GitHub Desktop.
Gist for this blogpost: https://asontu.github.io/2022/05/09/revisited-sitecore-path-in-sql-query.html
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 RootItems as ( | |
select cast(rt.ID as uniqueidentifier) ID, cast(rt.Path as nvarchar(max)) Path | |
from (select ''n)t | |
cross apply ( values | |
('{0DE95AE4-41AB-4D01-9EB0-67441B7C2450}', '/sitecore/content'), | |
('{B701850A-CB8A-4943-B2BC-DDDB1238C103}', '/sitecore/Forms'), | |
('{3D6658D8-A0BF-4E75-B3E2-D050FABCF4E1}', '/sitecore/media library'), | |
('{B26BD035-8D0A-4DF3-8F67-2DE3C7FDD74A}', '/sitecore/templates/Foundation'), | |
('{8F343079-3CC5-4EF7-BC27-32ADDB46F45E}', '/sitecore/templates/Feature'), | |
('{825B30B4-B40B-422E-9920-23A1B6BDA89C}', '/sitecore/templates/Project'), | |
('{B29EE504-861C-492F-95A3-0D890B6FCA09}', '/sitecore/templates/User Defined'), | |
('{E24C4A00-08D6-41C8-B60E-E7990B21697A}', '/sitecore/templates/Branches/Foundation'), | |
('{AD71FACC-3C23-4DF8-A427-672020DB5612}', '/sitecore/templates/Branches/Feature'), | |
('{A1F6469D-16E1-4A5F-9E49-1AAD869A5D11}', '/sitecore/templates/Branches/Project'), | |
('{F03DED1F-B02B-49A1-B4C0-793C6F092CFD}', '/sitecore/templates/Branches/User Defined') | |
) rt(ID,path) | |
), ItemPaths as ( | |
select r.ID, r.Path | |
from RootItems r | |
union all | |
select i.ID, p.Path + '/' + i.Name | |
from ItemPaths p | |
join dbo.Items i on i.ParentID = p.ID | |
) | |
select top 10 * | |
from ItemPaths |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment