Sublayout Usage - Sitecore

Overview

This article describes a way to query your Sitecore database to determine where a sublayout is used.

Solution

This solution requires the dbo.ItemTree view, available here.

declare 
    @mySublayoutID uniqueidentifier = '4F63F6B1-2010-4F28-B71D-EBAEDE013592' 
    
select 
    t.*
    
from 
    dbo.Fields f
    
    inner join dbo.ItemTree t
        on f.ItemId = t.ID
        
where 1=1
    and FieldId = 'F1A1FE9E-A60C-4DDB-A3A0-BB5B29FE732E'
    and Value like '%<r id="{' + CONVERT(varchar(100), @mySublayoutID) + '}"%'