Thursday, April 10, 2014

Reviewing SQL Schema Dates

Josh,

So you're wanting to know some basic dates around a schema in SQL Server.  Unfortunately the "sys.schemas" view doesn't have anything to indicate create or modify dates.  Furthermore if the schema creation isn't logged, then the only way to review this is to relate the schema to the "sys.objects" view.

Here is the query to looks at this:

select
   
ss.name,
   
count(so.object_idas ObjectCount,
   
min(so.create_dateas EarliestCreateDate,
   
max(so.create_dateas LatestCreateDate,
   
min(so.modify_dateas EarliestModifyDate,
   
max(so.modify_dateas LatestModifyDate
from
   
sys.schemas ss
   inner join
   
sys.objects so on so.schema_id ss.schema_id
group by
   
ss.name
order by
   
LatestModifyDate desc
 

No comments:

Post a Comment

Please only include comments that add to the substance of the Blog Post:
- Question or request for clarification
- Idea for improvement
- Identifying an issue

Please refrain from promotion.