Find all closed Web Parts in Content Database

Use this script to find all the closed web parts in your content database:

SELECT     w.fullurl + '/' + ad.dirname + '/' + ad.leafname
FROM         WebParts wp, alldocs ad, sites s, webs w
where tp_isincluded = 0
and wp.tp_pageurlid = ad.id
and ad.siteid = s.id
and webid = w.id