MSSQLCity.Com - All about MS SQL
     
About Us  
SSWUG Articles  
Articles  
FAQ  
Administration  
Backup/Restore  
Connectivity  
Development  
General  
Installation  
OLAP  
Replication  
Transfer/move  
Trouble  
SQL 6.5  
Scripts  
Tips  
Test Exams  
Advertise  
Download  
History  
Search  
Traffic  
Related Links  
     
Your button logo
Add to Favorites
 
     
 


How can I compare the data in two tables with identical structure?

Answer:

1. Compare the row counts in these tables by using the COUNT(*) function:

SELECT COUNT(*) FROM tb1
SELECT COUNT(*) FROM tb2

2. If the row counts in the tables is identical, you can download the data from these tables into files on the disk by using the bcp utility and compare the size of these files.

To get more information about what rows are differ, you can compare these files by using the comp.exe utility (C:\WINNT\system32 - path by default for Windows NT).

3. You can use red-gate SQL compare to do this. It can compare tables, constraints, rules, stored procedures and creates a script for applying the changes from one database to another.
You can download the 14 days trial version at here:
http://www.red-gate.com

See also this link:
How can I compare two databases?


 

 
Visit The SQL Server Worldwide User's Group for all the latest news and information about SQL Server, Oracle, DB2 and XML for developers and administrators.

(c) 1997, 2005 Bits on the Wire, Inc