Date object last modified
Asked Answered
P

4

8

How can I find out the date a MS SQL Server 2000 object was last modified?

I need to get a list of all the views, procs, functions etc that were modified since Aug 15th. In sysObjects I can see the date objects were created but I need to know when they were last altered.

NB: this is an SQL 2000 database.

Philina answered 16/9, 2008 at 23:55 Comment(1)
For others who might find this post and be looking for what I was select * from sys.all_objects order by modify_date desc gets this information in SQL 2008 R2Hogarth
I
6

Note that SQL Server actually does not record the last modification date. It does not exist in any system tables.

The Schema Changes History report is actually constructed from the Default Trace. Since many admins (and web hosts) turn that off, it may not work for you. Buck Woody had a good explanation of how this report works here. The data is also temporary.

For this reason, you should never RELY on the Schema Changes History report. Alternatives:

  • Use DDL Triggers to log all schema modification to a table of your choosing.
  • Enforce a protocol where views and procs are never altered, they are only dropped and recreated. This means the created date will also be the last updated date (this does not work with tables obviously).
  • Vigilantly version your SQL objects and schema in source control.

--

Edit: saw that this is SQL 2000. That rules out Default Trace and DDL Triggers. You're left with one of the more tedious options I listed above.

Inspirational answered 17/9, 2008 at 0:21 Comment(1)
thanks for the suggestions which will help as we move forward. Guess I am stuck for getting a retrospective list at this point.Philina
F
15

I know this is a bit old, but it is possible to view the last altered date of stored procs and functions with this query:

USE [Your_DB]    
SELECT * FROM INFORMATION_SCHEMA.ROUTINES

Just thought it would be nice to mention this since I searched for this very solution and this thread was misleading.

Freya answered 26/2, 2010 at 16:12 Comment(1)
Exactly what i was seeking for, thank you very much !Inn
I
8

I have got confirmed Answer for above any procedure History for modified date with below query

Step -1 Execute the procedure on DB

SELECT name, create_date, modify_date 
FROM sys.objects
WHERE type = 'p' 

Step -2 Then copy the text to Excel with headers

select route coloumn and then paste the exact procedure name into ^F window and press enter you will get exact modified date.

Regards, Sudhir Pune

Iniquitous answered 18/3, 2014 at 7:9 Comment(0)
I
6

Note that SQL Server actually does not record the last modification date. It does not exist in any system tables.

The Schema Changes History report is actually constructed from the Default Trace. Since many admins (and web hosts) turn that off, it may not work for you. Buck Woody had a good explanation of how this report works here. The data is also temporary.

For this reason, you should never RELY on the Schema Changes History report. Alternatives:

  • Use DDL Triggers to log all schema modification to a table of your choosing.
  • Enforce a protocol where views and procs are never altered, they are only dropped and recreated. This means the created date will also be the last updated date (this does not work with tables obviously).
  • Vigilantly version your SQL objects and schema in source control.

--

Edit: saw that this is SQL 2000. That rules out Default Trace and DDL Triggers. You're left with one of the more tedious options I listed above.

Inspirational answered 17/9, 2008 at 0:21 Comment(1)
thanks for the suggestions which will help as we move forward. Guess I am stuck for getting a retrospective list at this point.Philina
M
1

This is not always correct because modify_date is Date the object was last modified by using an ALTER statement. If the object is a table or a view, modify_date also changes when a clustered index on the table or view is created or altered.

Mareld answered 8/6, 2015 at 17:30 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.