I have tried to construct a script of my own. I am able to locate the tables that do not exist in on of the datatbase. My problem is now, how would I copy the tables that exist in one database to the other database where they do no exist.The script i have witten so far is show below:ALTER PROCEDURE SP_ZCOMPARE_AND_LOAD(@DBNAME1 SYSNAME,@DBNAME2 SYSNAME)AS BEGIN-- Check if table exists exists. If so show error IF @DBNAME1 IS NULL BEGIN RAISERROR( 'First database entered is null', 16 , 1) RETURN END IF @DBNAME2 IS NULL BEGIN RAISERROR( 'Second database entered is null', 16 , 1) RETURN END IF DB_ID(@DBNAME1) IS NULL BEGIN RAISERROR( 'First database does not exist', 16 , 1) RETURN END IF DB_ID(@DBNAME2) IS NULL BEGIN RAISERROR( 'Second database does not exist', 16 , 1) RETURN END --=========================================================================== --GET TABLES THAT DO NOT EXIST IN OTHER DATABASEDECLARE @command VARCHAR(2048)set @command = 'SELECT A.[id] ,B.[id] ,a.[name] ,b.[name] from (Select * from [' + @DBNAME1 + '].dbo.sysobjects where xtype = ''u'') as A FULL OUTER JOIN (SELECT * from [' + @DBNAME2 + '].dbo.sysobjects where xtype = ''u'') as B ON B.[name] = A.[name] and B.[id] = A.[id] WHERE B.name is null or A.name is null'PRINT @commandEXEC (@Command)RETURN END
Any help would be much appreciated