Is there any good tool which can compare the resultset for 2 queries and highlight the difference. This could be particularly useful when the queries are re-written for performance tuning and we want to be sure that the query produces same result. I was using Quest SQL optimizer to compare original and re-written queries but the tool stops at just counting the number of rows, some form of actual data comparison should be very helpful.
+1
A:
If query Q1 and query Q2 return the same number of rows this query will check that they return exactly the same data:
select count(*) from
( select * from q1
intersect
select * from q2 )
/
That is, the outcome should be the same number as the number of rows returned by each query when run standalone.
APC
2010-04-22 06:22:30