Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 SQL Server Administration (2000)
 Compare 2 databases(tables)

Author  Topic 

malletts
Starting Member

16 Posts

Posted - 2005-04-27 : 07:26:15
hi all,

can anyone advise of any utilities that can be used that
compare 2 databases (mainly just the tables) to see if they
are identical?


thanks,
stephen

mr_mist
Grunnio

1870 Posts

Posted - 2005-04-27 : 07:28:59
Look at the adverts on here.

-------
Moo. :)
Go to Top of Page

JamesH
Posting Yak Master

149 Posts

Posted - 2005-04-27 : 07:42:29
You might want to look at the information_schema views as well. Here's a sample to compare tables between two databases:

CREATE Proc rsp_compare_tbls (@OldDB nvarchar(30),
@NewDB nvarchar(30))
as
Declare @SQL varchar(4000)
truncate table s_TblChangesOnly


set @SQL = 'insert s_TblChangesOnly
select TABLE_CATALOG as VERSION, TABLE_NAME, ''Removed'' as STATUS
from ' + @OldDB + '.information_schema.TABLES
where TABLE_TYPE = ''BASE TABLE''
and TABLE_NAME not in (select TABLE_NAME
from '+ @NewDB + '.information_schema.TABLES
where TABLE_TYPE = ''BASE TABLE'')
Union ALL
select TABLE_CATALOG as VERSION, TABLE_NAME, ''New'' as STATUS
from ' + @NewDB + '.information_schema.TABLES
where TABLE_TYPE = ''BASE TABLE''
and TABLE_NAME not in (select TABLE_NAME
from ' + @OldDB + '.information_schema.TABLES
where TABLE_TYPE = ''BASE TABLE'')
order by TABLE_CATALOG, TABLE_NAME'

Exec (@SQL)

select * from s_TblChangesOnly

You also have the ability to query columns, views, etc.

HTH,

JamesH.
Go to Top of Page

ajthepoolman
Constraint Violating Yak Guru

384 Posts

Posted - 2005-04-27 : 12:31:19
http://www.database-comparison.com
Go to Top of Page

bakerjon
Posting Yak Master

145 Posts

Posted - 2005-04-27 : 14:09:57
www.red-gate.com
www.embarcadero.com


Now I know, and knowing is half the battle!
http://www.sqlteam.com/forums/topic.asp?TOPIC_ID=48013

Go to Top of Page
   

- Advertisement -