Thursday, April 10, 2014

Reviewing SQL Schema Dates


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:

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
sys.schemas ss
   inner join
sys.objects so on so.schema_id ss.schema_id
group by
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.