Traditionally, query processing gets a query and a database instance as input and returns the result of the query for that particular database instance. Reverse query processing (RQP) gets a query and a result as input and returns a possible database instance that could have produced that result for that query. Rather than making a closed world assumption, RQP makes an open world assumption. There are several applications for RQP; most notably, testing database applications and debugging database applications. This paper describes the formal framework of RQP and the design of a system, called SPQR (System for Processing Queries Reversely) that implements a reverse query processor for SQL.