Friday, April 26, 2013

TSQL query to find webparts in SharePoint content databases


select d.DirName + ‘/’ + d.LeafName as [URL]
,w.tp_ID as [GUID for WebPart]
,w.tp_ZoneID as [WebPart Zone]
,tp_WebPartTypeID as [Web Part Type ID]
,tp_DisplayName
,tp_ContentTypeId
from SharePoint_Content_01.dbo.AllDocs d WITH(NOLOCK)
join SharePoint_Content_01.dbo.WebParts w WITH(NOLOCK)
on w.tp_PageUrlID = d.Id and w.tp_SiteId = d.SiteId
where d.IsCurrentVersion = 1
and DirName like ‘%Acquisition%’
and LeafName like ‘%default.aspx’
union
select d.DirName + ‘/’ + d.LeafName as [URL]
,w.tp_ID as [GUID for WebPart]
,w.tp_ZoneID as [WebPart Zone]
,tp_WebPartTypeID as [Web Part Type ID]
,tp_DisplayName
,tp_ContentTypeId
from SharePoint_Content_02.dbo.AllDocs d WITH(NOLOCK)
join SharePoint_Content_02.dbo.WebParts w WITH(NOLOCK)
on w.tp_PageUrlID = d.Id and w.tp_SiteId = d.SiteId
where d.IsCurrentVersion = 1
and DirName like ‘%Acquisition%’
and LeafName like ‘%default.aspx’

No comments:

Post a Comment