select all rows with a question mark I've been asked to check an entire database for all records with a question mark (?). I assume I can only do this on a table basis, is there any short cut or do I have to run

SELECT * FROM [table] WHERE [field] LIKE '%?%' 

for each column?
Your objective is slightly ambiguous:


  all records with a question mark (?)


Columns that are not character data types may or may not contain a question mark, depending on their text representation.

Also, this could mean to filter for any columns equaling '?' or just containing '?'.

A dead simple solution for the "containing" interpretation (and ignoring my first concern - which seems safe enough for '?') is to cast the whole row to text - generating the default text representation of everything, plus delimiters and decorators - none of which include the question mark (?) per default:

SELECT * FROM tbl t WHERE t::text LIKE '%?%';


You would run this for every (relevant!) table in the DB. (You'll want to exclude system tables at least.) I added an example implementation to the related question on SO:


How to search a specific value in all tables (PostgreSQL)?


Related answer on SE Code Review:


SQL: Search for a keyword in several columns of a table