Finding specific renderings using sitecore query

Recently I was helping a content editor by moving items in the content tree. We successfully move almost all items apart from a couple. These were advert items which referenced on various pages within the renderings using data source. Hence referenced as path and not the Sitecore Item Guid. Some moving them would break the links and we didn’t know on which pages these were referenced.

We did a search using Sitecore Rocks but the way these were referenced and the current version of Rocks didn’t support path searching. We were bit clueless. One of my fellow developers suggested writing a bit of Sitecore Query to get what we were after.

We wrote something like

select @@id, @@name, @__Renderings from /sitecore/content/home//*[contains(@__Renderings,’ds=”/sitecore/content/home/caring/apply for job”‘)];

This helped us find a specific type of renderings which referenced using data-source and they were placed within specific sublayouts.