Black Friday – Cyber Monday: 30% off dbSlice Desktop and Pro until Dec 2. See pricing →

Compare data between two databases, key by key

Use cases · · 2 min read

A copy that "finished without errors" can still be wrong: a batch that failed halfway, a filter that was too strict, a row updated at the source while the job ran. Counting rows on both sides will not tell you which ones. Comparing by key will.

What Compare data reports

Compare data reads both sides and writes nothing. Either side can be a table, a view or a SELECT, and a WHERE filter and a column mapping limit what is compared, so a column that is expected to differ (a load timestamp) does not flood the report. It reports the rows in each side, the rows matched by key, the keys missing in the target, the keys missing in the source and, with Also compare column values, the rows whose values differ and the column that differs.

A second screen compares structure: columns that exist on one side only and differences in type, nullability, primary key or identity.

Available from the Desktop edition; the same screen runs from the command line as a Status job.

dbSlice Compare data tab

A compare, step by step

  1. Pick both sides. Source and target, each a table, view or SELECT, with the key column. Apply a WHERE or map the columns if the two sides are not identical.
  2. Compare. Turn Also compare column values on when you need the values, off when keys are enough (faster).
  3. Read the result. Summary on screen: matched, missing in target, missing in source, different values. The report can be saved as HTML (with a review block for QA) or CSV.
  4. Act on the keys. Copy the divergent keys as KEY IN (…) or save the full lists to files, then re-sync only those rows, or run the generated query on each side to look at them.
  5. Schedule it. Save the screen and run it as a Status job. The job can be set to fail when differences exist, so a scheduler or an alert notices.

Where it fits

  • Day to day: confirm that a sync or a refresh really matched, and see only the rows that differ.
  • Mission-critical: leave evidence before and after a cutover: an on-screen report, an HTML or CSV file and the full list of divergent keys to re-sync only those rows.

dbSlice shows the difference; your team decides which side is right and what to fix. Compare data is evidence for your check, not a substitute for it.

Not using dbSlice yet?
Try the free version on the Microsoft Store: it connects, browses data, compares structures and exports to CSV.

Try it free Watch the demos