SQL Server stored procedure version control-DDL triggers

Source: Internet
Author: User

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

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.