select case type when 'C' then 'check constraint' when 'D' then 'default' when 'F' then 'foreign key' when 'FN' then 'function' when 'K' then 'primary key' when 'P' then 'stored procedure' when 'S' then 'system table' when 'TF' then 'table function' when 'TR' then 'trigger' when 'U' then 'user table' when 'V' then 'view' else type end as type, odev.name from DevDb.dbo.sysobjects odev inner join DevDb.dbo.sysprotects pdev on odev.id = pdev.id inner join DevDb.dbo.sysusers udev on udev.uid = pdev.uid where 1=1 and udev.name = 'public' and pdev.protecttype in (204,205) and odev.name not in (select distinct oprod.name from ProdDb.dbo.sysobjects oprod inner join ProdDb.dbo.sysprotects pprod on oprod.id = pprod.id inner join ProdDb.dbo.sysusers uprod on uprod.uid = pprod.uid where 1=1 and uprod.name = 'public' and pprod.protecttype in (204,205) ) order by 1,2