|
|
|
|
|
|
| Author |
Message |
Thomas Gagne *nix forums beginner
Joined: 15 Mar 2005
Posts: 35
|
Posted: Thu Jul 06, 2006 6:42 pm Post subject:
How to verify two tables are IDENTICAL
|
|
|
For various reasons, we need to BCP-out of one database and BCP-in to
another. If both are on the same server what is the surest way to
compare two tables to make sure they're identical? I want to know that
each has the same number of rows with the identical information in each row.
I was wondering if there's a way to calculate a table's HASH and compare
the two HASHes. |
|
| Back to top |
|
 |
bret@sybase.com *nix forums addict
Joined: 24 May 2005
Posts: 66
|
Posted: Fri Jul 07, 2006 2:23 am Post subject:
Re: How to verify two tables are IDENTICAL
|
|
|
Thomas Gagne wrote:
| Quote: | For various reasons, we need to BCP-out of one database and BCP-in to
another. If both are on the same server what is the surest way to
compare two tables to make sure they're identical? I want to know that
each has the same number of rows with the identical information in each row.
I was wondering if there's a way to calculate a table's HASH and compare
the two HASHes.
|
Assuming the table has a primary key (not one of those odd cases
that allows duplicate rows) I think something like
select count(*) from db1..a
go
select count(*) from db2..b
go
select count(*) from db1..a, db2..b where a.c1 = b.c1 and a.c2 = b.c2
and ... a.cn = b.cn
go
If all three counts are the same, the two tables contain identical
data.
If the tables are on different servers that can talk to each other over
a network, then a proxy table could be used.
I suppose you could write a HASH function in Java, but I think it would
be hard
to guarantee that two identical HASH values really meant the data was
identical
and not merely two different sets of data that happen to produce the
same HASH value.
-bret |
|
| Back to top |
|
 |
Google
|
|
| Back to top |
|
 |
|
|
The time now is Sun Nov 23, 2008 12:05 pm | All times are GMT
|
|
Remortgages | Loan | Free Advertising | Cheap Loan | Loans
|
|
Copyright © 2004-2005 DeniX Solutions SRL
|
|
|
|
Other DeniX Solutions sites:
Unix/Linux blog |
electronics forum |
medicine forum |
science forum |
|
|
Privacy Policy
|
Powered by phpBB © 2001, 2005 phpBB Group
|
|