CREATE trigger [SQLInfoNewTrigger]
on database
for create_procedure, alter_procedure, drop_procedure, --events
create_table, alter_table, drop_table,
create_function, alter_function, drop_function
as
set nocount on
declare @data xml
set @data = EVENTDATA()
insert into databasename.dbo.SQLINFONEW(DatabaseName,EventType,ObjectName,ObjectType,LoginName,TSQLCommand,date)
values
(@data.value('(/EVENT_INSTANCE/DatabaseName)[1]','varchar(50)'),
@data.value('(/EVENT_INSTANCE/EventType)[1]', 'varchar(50)'),
@data.value('(/EVENT_INSTANCE/ObjectName)[1]', 'varchar(50)'),
@data.value('(/EVENT_INSTANCE/ObjectType)[1]', 'varchar(50)'),
@data.value('(/EVENT_INSTANCE/LoginName)[1]', 'varchar(50)'),
@data.value('(/EVENT_INSTANCE/TSQLCommand)[1]', 'varchar(max)'),
getdate()
)
Wednesday, December 2, 2009
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment