Thursday, September 18, 2008

Compare schema between two databases

This is a bit rough, but the idea is to quickly find schema discrepancies between database1 and database2.
SELECT
 l.name, l.type_desc,
 m.name, m.type_desc
FROM database1.sys.objects as l
 full outer join database2.sys.objects as m on m.name = l.name
WHERE
   l.name is null or
   m.name is null