Skip to content
David Cumps
Search File Contents

Search File Contents

Originally published on my old blog at cumps.be on August 5, 2007.

When using the Windows Search functionality, you can search for words inside files. By default, however, this doesn’t seem to work for .sql or .php files.

To enable this, add the following keys to the registry:

[HKEY_CLASSES_ROOT\.sql\PersistentHandler]
@="{5e941d80-bf96-11cd-b579-08002b30bfeb}"

[HKEY_CLASSES_ROOT\.php\PersistentHandler]
@="{5e941d80-bf96-11cd-b579-08002b30bfeb}"

This will associate the plain text filter (System32\Query.dll) with the specific file type, making it possible to search the content of the file. Not all extensions have this enabled by default, for performance reasons from Microsoft’s point of view. I personally haven’t noticed any visible performance problems from enabling it for SQL and PHP files.

Log off and log on again. From then on you can use the search box to search inside SQL and PHP files. A quick way to make Windows recognize the change is to kill the explorer.exe process and start a new one. That way you don’t have to close any programs.

At pilif.ch you can find a nice tool to set the PersistentHandler to the plain text filter.

Give it a try and search for ‘SELECT’.

Update: since Windows Vista you can set this without the registry, in Indexing Options > Advanced > File Types, by choosing “Index Properties and File Contents” for an extension.

You May Also Like