We needed to check which modules were NOT being used on a DNN site. Why? It's a multi-portal DNN 3.1 website with quite a few 3rd party modules on it and we wanted to know which modules were not in use so we could remove them from the DNN installation before performing an upgrade. No need to add extra compilications or search for module updates for modules that were not being used. And if they are not being used, why leave them on there adding to the bloat? Anyway, here is the SQL:
SELECT ModuleDefinitions.ModuleDefID, ModuleDefinitions.FriendlyName, ModuleDefinitions.DesktopModuleID
FROM ModuleDefinitions LEFT OUTER JOIN
Modules ON ModuleDefinitions.ModuleDefID = Modules.ModuleDefID
WHERE (Modules.ModuleDefID IS NULL)