April 4, 2007 at 10:38 am
Guys,
Is there a way to find out when a certain DB object (e.g. Stored procedure) was last modified?
SYSOBJECTS table contains crdate and refdate fields. None of these, however, appear to tell me when when the object was last updated.
Any suggestions?
Thanks a lot
April 4, 2007 at 8:12 pm
No such thing in SQL Server 2000. You can make one with a trigger on each table and a "LastModified" table... just be careful not to make any deadlocks...
--Jeff Moden
Change is inevitable... Change for the better is not.
April 5, 2007 at 5:48 am
In SQL 2005, you can use DDL triggers to keep audit trails of object changes as well.....something like.....
CREATE TABLE [dbo].[DDLAuditLog](
[EventType] [nvarchar](100) NULL,
[XMLCommand] [xml] NULL,
[PostTime] [datetime] NULL,
[HostName] [nvarchar](100) NULL,
[LoginName] [nvarchar](100) NULL
)
GO
CREATE TRIGGER [dbtr_AuditOperations]
ON DATABASE
FOR DDL_DATABASE_LEVEL_EVENTS
AS
DECLARE @data XML
DECLARE @posttime datetime
DECLARE @hostname NVARCHAR(100)
DECLARE @loginname NVARCHAR(100)
DECLARE @eventtype NVARCHAR(100)
-- Retrieve the event data XML
SET @data = eventdata()
-- Extract data from the XML
SET @posttime = CONVERT(NVARCHAR(24),@data.query('data(//PostTime)'))
SET @eventtype = CONVERT(NVARCHAR(100),@data.query('data(//EventType)'))
-- Retrieve other system information
SET @hostname = HOST_NAME()
SET @loginname = SYSTEM_USER
-- Write event data to the log table
INSERT INTO dbo.DDLAuditLog(EventType, XMLCommand, PostTime,HostName,LoginName)
VALUES(@eventtype, @data, @posttime, @hostname, @loginname)
GO
ENABLE TRIGGER [dbtr_AuditOperations] ON DATABASE
GO
April 5, 2007 at 7:26 am
In SQL 2000, the "version" field will change on alters. May change on a few other index things, but alters for sure. You can track this
http://www.sqlservercentral.com/columnists/sjones/20010423065956_1.asp
Doesn't give you a date unless you track it everyday.
April 10, 2007 at 10:37 am
Thanks for the suggestions guys.
Steve: I am reading your link now ... very useful!
April 10, 2007 at 2:34 pm
Hope it helps. Remember to that unless you track it regularly, like every day, you won't know when it changed.
April 10, 2007 at 2:44 pm
Yes, I am aware of that.
Thank you
Viewing 7 posts - 1 through 6 (of 6 total)
You must be logged in to reply to this topic. Login to reply