Thursday, October 14, 2010

DotNetNuke - A SQL Query to display all pages containing specific text

Ever wanted to find all of the pages on your site that contained a specific text string (such as 'Coming Soon')in and HTML/Text module? Here is a query that will help. Keep in mind that a single page can have multiple modules that contain this text, that is why we are using the DISTINCT keyword on our TabID Query. We put percentage signs on each side of the text we are searching for to indicate that there could be other text before or after our search string.

SELECT tabpath, tabname FROM [Tabs] WHERE tabid in
(
     SELECT DISTINCT(tabid) FROM [TabModules] WHERE moduleid IN
     (
          SELECT ModuleID FROM [HtmlText] 
          WHERE content LIKE '%Coming Soon%'
     )
)

No comments:

Post a Comment