SQL通过ContentTypeID找使用了内容类型的列表库
DECLARE @ContentTypeID nvarchar(128)
SET @ContentTypeID='0x1B452DB25E92A34DA3E35FC8731278D2'
SELECT w.Title AS [Web Site], w.FullUrl AS [Web Url], al.tp_Title AS [List Title], ct2.*
FROM ContentTypes ct1
JOIN ContentTypes ct2
ON LEFT(ct2.ContentTypeId, Len(ct1.ContentTypeId))=ct1.ContentTypeId
LEFT OUTER JOIN dbo.ContentTypeUsage ctu
ON LEFT(ctu.ContentTypeId, Len(ct2.ContentTypeId)) = ct2.ContentTypeId
LEFT OUTER JOIN dbo.AllLists al
ON ctu.ListId = al.tp_Id AND ctu.WebId=al.tp_WebId
LEFT OUTER JOIN dbo.Webs w
ON al.tp_WebId = w.Id
where charindex( @ContentTypeID,sys.fn_varbintohexstr(ct1.ContentTypeId))>0备注:删除内容类型前,要删除使用了内容类型的列表库,包括回收站内的