Last active
March 11, 2016 15:30
-
-
Save JamesSkemp/8341996 to your computer and use it in GitHub Desktop.
Searches Sitecore field values for a search term, via SQL.
This file contains hidden or 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
use XXX_Sitecore_Master | |
declare @searchTerm varchar(100) | |
declare @onlySearchLayouts bit | |
/* | |
If using parameters, they must be escaped: | |
%2b = space | |
%252f = / | |
If using DataSource, they don't. | |
*/ | |
set @searchTerm = 'studentbio' | |
set @onlySearchLayouts = 0 | |
select top 10 * | |
from SharedFields f | |
left join Items i on f.ItemId = i.ID | |
where Value like '%' + @searchTerm + '%' | |
If @onlySearchLayouts <> 1 | |
BEGIN | |
select top 10 * | |
from ArchivedFields f | |
left join Items i on f.ItemId = i.ID | |
where Value like '%' + @searchTerm + '%' | |
select top 10 * | |
from UnversionedFields f | |
left join Items i on f.ItemId = i.ID | |
where Value like '%' + @searchTerm + '%' | |
select top 10 * | |
from VersionedFields f | |
left join Items i on f.ItemId = i.ID | |
where Value like '%' + @searchTerm + '%' | |
END |
If using LINQPad, consider the gist at https://gist.github.com/JamesSkemp/94159859a148b2dbf3d6 instead.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
If setting additional parameters on layout items you need to escape slashes and spaces.
set @searchterm = 'Sidebar%2bTextbox%252fMBA%252fCorporate%2bFinance%252f'