The trigger starts after making a change, as far as I can tell, there is no access to the values ββ"earlier". EVENTDATA () is defined and the previous condition is not provided. As a result, you will just need to write the current value in the log. However, if you pre-populated your journal with this command:
INSERT INTO dbo.tblQueryAudit (ObjectName, TSQLCommand) SELECT o.Name,m.definition FROM sys.objects o INNER JOIN sys.sql_modules m ON o.object_id=m.object_id WHERE type='P'
you can use your trigger and still have a complete picture of all the changes. Your log will contain all previous versions, as well as the current version of each procedure. You can use my trigger version (see below), where you will have access to some other columns from sys.objects and sys.sql_modules, for example:
uses_ansi_nulls uses_quoted_identifier is_schema_bound null_on_null_input principal_id
which may also be useful for registration. alternative version:
CREATE trigger trgDDLAuditQuery on database for alter_procedure as begin set nocount on; DECLARE @EventData xml SET @EventData=EVENTDATA() INSERT INTO dbo.tblQueryAudit (ObjectName, TSQLCommand)
source share