Comparing SQL Query Outputs

Query Result Sets Analyzer allows you to compare results of two SQL SELECT statements executed in the same or different SQL Editors. You can compare two results sets produced in the same SQL Editor if the result sets are retrieved from the same database server. You can compare two result sets produced in different SQL editors when results sets are retrieved from two different database servers.

To compare two query result sets:

Execute first SQL SELECT in the SQL Editor. After the result set is produced, press Pin button located on the result set toolbar to keep this result set. Execute second SQL SELECT statement in this SQL Editor. *** NOTE *** You can also achieve the same result if you execute two SQL SELECT statements at the same time as a script, with statements separated by ; separator character. Both result sets will be produced at the same time in two Output tabs in the SQL Editor (they also can be produced in one tab - one above another - if you choose Results in Single Tab option before executing the script).

*** NOTE *** If a second query should be executed against a different database server, you will have to open a second SQL Editor connected to that database server and execute the query from the second editor.

After both result sets are produced, select any result set grid by clicking on it and choose Compare Data from the popup menu. Second level of the popup menu shows all results sets produced in all opened SQL Editors in the following form :. Choose the second result set that you want to use for a comparison. The Query Result Sets Diff Analyzer window will open.

Query Result Sets Diff Analyzer window displays Columns Mapping group at the bottom that automatically matches by name columns of source and target result sets. You can also manually add pairs of columns for comparison if two results have different column names that contain similar data to compare. To manually add a pair of column, press Add button and use Source Column and Target Column dropdown lists to create a pair of columns to compare. Check PK column for column pairs represent primary key of result sets. Primary Key should include a group of columns that define a unique row of data. For example, it can be either some ID column or group of columns that are part of unique index. *** NOTE *** You can press Refresh button, if you re-executed query in the SQL Editor after Diff Analyzer window was opened and you want to compare newly produced result sets without having to close and reopen Query Diff Analyzer window.

Press Next button to compare selected result sets. The comparison results page displays a grid that contains added, deleted and modified rows. To see details for each row, click on that row in the grid. The details for the selected row will be displayed in the bottom grid. If the data in the selected row was modified, the bottom grid shows column name, in which data was modified, and source and target values side by side. Default display mode is to show only those columns that are modified in a target result set. If you want to see values for all row’s columns that were compared, uncheck Show Difference Only checkbox.