How to use SQL to delete/disable a DNN module on a page

DNN > How To
Sometimes a module will cause errors on a page which make it inaccessible.  This can make it a bit difficult to turn off the module to bring the page back up.  If you're seeing an error like this, you can use the following SQL script to disable modules on a specific page.
Make sure you take a backup of your site before proceeding.  Although this query isn't particularly dangerous , it's always best to take a backup before to be sure.  If you do delete the wrong modules with it - they're sent to the DNN recycle bin.
USE database
UPDATE TabModules
SET IsDeleted = 'True'
WHERE TabID in (
        /*Replace Site path with everything after the TLD (.com/.net/  You'll need to double any forward         slashes.  For example:   would become //about//dogs//zippy
	WHERE TabPath = 'Site path'
AND ModuleID IN(
SELECT ModuleID FROM Modules 
WHERE ModuleDefID in
	SELECT ModuleDefID FROM ModuleDefinitions 
        /*Replace the text inside the single quotes with the exact name of the module*/
	WHERE FriendlyName = 'Friendly name of module' 
        /*Option 2:  Remove the line above this, then on the line below remove the /* and */ and replace the text between the % signs with a piece of the modules name*/
        WHERE FriendlyName LIKE '%part of name%'  

Troubleshooting issues with this expression:
1)  No rows affected:  The site path might incorrect.  If you can see the TabID in the URL, switch the WHERE TabID IN(...) statement to the following:
WHERE TabID ='###'
Replace the #'s with the TabID number you saw.  If you don't see the TabID, you'll need to look in the database.  The following query should help you narrow down your search for the proper TabID, just replace name with a word from the path:
USE database
WHERE TabPath LIKE '%name%'
2)  Still no rows affected:  The name of the module is inconsistent with the entry in the database.  You can try making the query less precise by changing out to option 2, provided in the initial codeblock.  The LIKE operator parses the selected area for the text you feed into it, whereas the = operator searches for an exact match.
If you are having trouble identifying the friendly name of a module, the following query will give you a list of the modules on the page:
USE database
SELECT FriendlyName FROM ModuleDefinitions
WHERE ModuleDefID IN( select ModuleDefID from Modules
WHERE ModuleID IN (select ModuleID from TabModules
        /*Replace Site path with everything after the TLD, doubling forward slashes.*/
	WHERE TabPath = 'Site path'
Further questions:
If you are having trouble using this query, just open up a ticket with our support team and one of the staff would be happy to help you out!

Add Feedback