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