SET ANSI_NULLS ON GO SET QUOTED_IDENTIFIER ON GO CREATE trigger [Tracking_Alter_SP] on database for create_procedure, alter_procedure, drop_procedure, create_table, alter_table, drop_table, create_function, alter_function, drop_function as set nocount on SET ARITHABORT ON declare @data xml set @data = EVENTDATA() insert into changelog(databasename, eventtype, objectname, objecttype, sqlcommand, loginname,hostname) values( @data.value('(/EVENT_INSTANCE/DatabaseName)[1]', 'varchar(300)'), @data.value('(/EVENT_INSTANCE/EventType)[1]', 'varchar(60)'), @data.value('(/EVENT_INSTANCE/ObjectName)[1]', 'varchar(300)'), @data.value('(/EVENT_INSTANCE/ObjectType)[1]', 'varchar(50)'), @data.value('(/EVENT_INSTANCE/TSQLCommand)[1]', 'varchar(max)'), @data.value('(/EVENT_INSTANCE/LoginName)[1]', 'varchar(300)'), HOST_NAME() ) GO SET ANSI_NULLS OFF GO SET QUOTED_IDENTIFIER OFF GO
Friday, 14 December 2012
Track Alter stored procedure in Sql Server
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment