-- find last usage info,
-- how far back this information goes depends on the
-- server/database settings
select --
ss.name as SchemaName, so.name as SprocName
,so.create_date as SprocCreated, so.modify_date as SprocModified
,so.object_id
,stat.last_user_seek,stat.last_user_scan,stat.last_user_lookup,stat.last_user_update
,stat.last_system_seek,stat.last_system_scan,stat.last_system_lookup, stat.last_system_update
from sys.objects so
inner join sys.schemas ss on so.schema_id=ss.schema_id
left join sys.dm_db_index_usage_stats stat
on so.object_id=stat.object_id
where ss.name<>'sys' and so.type='P'
union
select
ss.name as SchemaName, so.name as SprocName
,so.create_date as SprocCreated, so.modify_date as SprocModified
,so.object_id
,stat.last_user_seek,stat.last_user_scan,stat.last_user_lookup,stat.last_user_update
,stat.last_system_seek,stat.last_system_scan,stat.last_system_lookup, stat.last_system_update
from db_dit.dbo.sys.objects so
inner join sys.schemas ss on so.schema_id=ss.schema_id
left join sys.dm_db_index_usage_stats stat
on so.object_id=stat.object_id
where ss.name<>'sys' and so.type='P'
order by case when stat.object_id is null then 0 else 1 end,ss.name,so.name
I'm trying to validate that my sproc changes from dev were pushed to sit properly in a simple query, but I can't seem to query the sys tables on the other db I get Invalid object name 'db_dit.dbo.sys.objects'.