Groups | Blog | Home
all groups > sql server (alternate) > april 2005 >

sql server (alternate) : Compare data in Tables


Leo
4/14/2005 10:36:25 PM
I am trying to determine the changes an application makes to a database.
The plan is to copy the existing schema (active) to a reference schema, run
the application and then diff the table data between the reference and the
a active schema. I have found one software vendor who has a tool to do
this, but it will only do one table at a time (interactively); I have more
then 300 and will run this a few times.

One other way of determining the changes, I guess, would be to log all sql
statements (in order), but I don't know how to do this (either).

Any pointers would be greatly appreciated.

Ray
4/14/2005 11:03:11 PM
If its changes you are looking for try running SQL Profiler against it.
Filter for where writes > 0. Another solution would to write a script to
doing the all tables comparison. Something like

Create a table with tablename, checksumbefore, checksumafter, rowsbefore,
rowsafter, numberofrowsdiff
Write a cursor of all user tables
For each table
Get count of rows with select count(*)
calc the CHECKSUM of each row and write to individual temp tables
select count(*) from checksumafter where checksum not in checksumbefore
insert/update the table

By the end of the script you should have indentified which tables change and
by how much.


[quoted text, click to view]

Malcolm
4/15/2005 12:52:01 AM
There is a software tool that can do this for you called DB Ghost
(www.dbghost.com). Its very fast at comparing data and can be run from
the command line for a fully automated process. A single command will
do any number of tables that you desire.

It's also the cornerstone of a full change management solution for SQL
Server databases i.e. it can build, compare and synchronize the schema
AND data directly from drop/create scripts held in a source control
system.

I highly recommend you check it out.
Vlad
5/10/2005 12:00:00 AM
"Malcolm" <malcolm.leach@innovartis.co.uk> wrote in
news:1113551521.457015.133450@l41g2000cwc.googlegroups.com:

[quoted text, click to view]

DB Ghost did exactly what I needed.

Thanks for your advice

AddThis Social Bookmark Button