The error you are getting is because you have some tables with foreign keys pointing to a non-existent table or a table that does not have a match on the target DB. To avoid this add this where clause in the dynamic string (line 304 more or less) :
where object_name(FK.referenced_object_id,db_id(”’+@TargetDB+”’)) is not null
]]>Are are getting this error for all the databases? I tried to reproduce the issue, but I couldn’t really do it. Could you send me the reproduction steps then I can have a look at it
]]>Msg 515, Level 16, State 2, Procedure sp_CompareDb, Line 275
Cannot insert the value NULL into column ‘FK_TABLE’, table ‘tempdb.dbo.#FKLIST_SOURCE
Any plans to add SP’s and triggers?
Also this may not really related to your sp, but I ran a test using SSMS Generate script wizard (2008r2) creating a db script from a db, changed the db name to create a dup db.
Then ran your compare sp between the two,
the compare listed several PK row deltas which when examined don’t appear to be actual deltas. If I create a 2nd dup from the generated script then compare with the first dup db your sp lists no differences. Any idea what this may indicate?
Is it hard to receive ??
I will need the same with the indexes …
Could You help me to change this script?
]]>