Stored Procedure versioning-DDL triggers – reference: Stored procedure version control Http://enjoyasp.net/?p=2431 CREATE TABLE [dbo]. [ChangeLog] ([logid] [int] IDENTITY (null,[databasename) [varchar] (COLLATE sql_latin1_general_cp1_ci_as not null,[ EventType] [varchar] (COLLATE sql_latin1_general_cp1_ci_as not null,[objectname] [varchar] (COLLATE sql_latin1_) General_cp1_ci_as not null,[objecttype] [varchar] (+) COLLATE sql_latin1_general_cp1_ci_as not Null,[sqlcommand] [ NVARCHAR] (max) COLLATE sql_latin1_general_cp1_ci_as not null,[eventdate] [datetime] Not NULL CONSTRAINT [df_eventslog_ Eventdate] default (getdate ()), [LoginName] [varchar] () COLLATE sql_latin1_general_cp1_ci_as not null, & nbsp [IP] [varchar] (sql_latin1_general_cp1_ci_as) COLLATE null ) on [primary] alter Trigger Backup_objectson all Server–all SERVER operations on all databases. Database: The operation of the current databases. On is used to specify the scope for Create_procedure, Alter_procedure, drop_procedure,create_table, alter_table, Drop_table,create_view, Alter_view, DrOp_view,create_function, Alter_function, Drop_functionasset nocount ondeclare @data xml Set @data = EVENTDATA () Insert int o BRM_TEST.dbo.changelog (databasename, EventType, objectname, ObjectType, SqlCommand, Loginname,ip) values (@ Data.value (' (/event_instance/databasename) [1] ', ' varchar '), @data. Value (' (/event_instance/eventtype) [ 1] ', ' varchar ', @data. Value (' (/event_instance/objectname) [1] ', ' varchar '), @data. Value (' (/ Event_instance/objecttype) [1] ', ' varchar '), @data. Value (' (/event_instance/tsqlcommand) [1] ', ' varchar ( Max), @data. Value (' (/event_instance/loginname) [1] ', ' varchar '), CONVERT (varchar (50), Connectionproperty (' client_net_address '))) GO–DDL Trigger http://msdn.microsoft.com/zh-cn/library/ms175941.aspx – View server-level triggers select TOP * from sys.server_triggers – View definition of server-level triggers select * from Sys.server_ sql_modules – viewing information about database events that fire triggers select TOP * FROM sys.server_trigger_events – remove DDL triggers on the server drop TRIGGER backup_objects on all server – fail DDL trigger disable TRIGGER backup_objects on all server – Get information about database-scoped triggers select * from sys.triggers – get information about database events that fire triggers select * from Sys.trigger_ events – View definition of database-scoped triggers select * from sys.sql_modules – delete DDL triggers on the current database drop TRIGGER backup_objects on DATABASE
SQL Server stored procedure version control-DDL triggers