Finding Pages Based on Linked Files using a SQL Script


This article furnishes a script to provide a quick way to view all the pages where certain types of files are currently linked. An example of where this might be useful would be when you need to update all links because a file name has changed.



  • Access to the SQL Server or SQL Console.



Producing a list of all pages, which contain specific files, can be accomplished with the following database script:


SELECT pa.HTTPAlias, REPLACE(t.TabPath, '//', '/'), ht.content
INNER JOIN portalalias pa ON t.PortalId = pa.PortalID
INNER JOIN tabmodules tm on tm.tabid = t.tabid
INNER JOIN htmltext ht on ht.moduleid = tm.moduleid
WHERE ht.Content LIKE '%.pdf%';


This script looks into the HTMLText table, which stores content from HTML modules, and searches for links with the specified extension.

  • In this case, it is .pdf, but you can change that value on the last line to another extension as needed (i.e. '%.docx%')


The script then takes the page containing the module and appends it to the portal alias to generate a full URL for the page where the link resides.

Lastly, it provides a copy of the HTML module content itself, which you will need to review and confirm it matches your expectations.


Additional Information




Please sign in to leave a comment.