SET ANSI_NULLS ONGOSET QUOTED_IDENTIFIER ONGOcreate trigger [tr_MStran_alterschemaonly] on database for ALTER_FUNCTION, ALTER_PROCEDURE as set ANSI_NULLS ON set ANSI_PADDING ON set ANSI_WARNINGS ON set ARITHABORT ON set CONCAT_NULL_YIELDS_NULL ON set NUMERIC_ROUNDABORT OFF set QUOTED_IDENTIFIER ON declare @EventData xml set @EventData=EventData() exec sys.sp_MStran_ddlrepl @EventData, 3GODISABLE TRIGGER [tr_MStran_alterschemaonly] ON DATABASEGO/****** Object: DdlTrigger [tr_MStran_altertable] Script Date: 2015/12/16 16:23:54 ******/SET ANSI_NULLS ONGOSET QUOTED_IDENTIFIER ONGOcreate trigger [tr_MStran_altertable] on database for ALTER_TABLE as set ANSI_NULLS ON set ANSI_PADDING ON set ANSI_WARNINGS ON set ARITHABORT ON set CONCAT_NULL_YIELDS_NULL ON set NUMERIC_ROUNDABORT OFF set QUOTED_IDENTIFIER ON declare @EventData xml set @EventData=EventData() exec sys.sp_MStran_ddlrepl @EventData, 1GODISABLE TRIGGER [tr_MStran_altertable] ON DATABASEGO/****** Object: DdlTrigger [tr_MStran_altertrigger] Script Date: 2015/12/16 16:23:54 ******/SET ANSI_NULLS ONGOSET QUOTED_IDENTIFIER ONGOcreate trigger [tr_MStran_altertrigger] on database for ALTER_TRIGGER as set ANSI_NULLS ON set ANSI_PADDING ON set ANSI_WARNINGS ON set ARITHABORT ON set CONCAT_NULL_YIELDS_NULL ON set NUMERIC_ROUNDABORT OFF set QUOTED_IDENTIFIER ON declare @EventData xml set @EventData=EventData() exec sys.sp_MStran_ddlrepl @EventData, 4GODISABLE TRIGGER [tr_MStran_altertrigger] ON DATABASEGO/****** Object: DdlTrigger [tr_MStran_alterview] Script Date: 2015/12/16 16:23:54 ******/SET ANSI_NULLS ONGOSET QUOTED_IDENTIFIER ONGOcreate trigger [tr_MStran_alterview] on database for ALTER_VIEW as set ANSI_NULLS ON set ANSI_PADDING ON set ANSI_WARNINGS ON set ARITHABORT ON set CONCAT_NULL_YIELDS_NULL ON set NUMERIC_ROUNDABORT OFF set QUOTED_IDENTIFIER ON declare @EventData xml set @EventData=EventData() exec sys.sp_MStran_ddlrepl @EventData, 2GODISABLE TRIGGER [tr_MStran_alterview] ON DATABASEGO/****** Object: DdlTrigger [TRG_VERSION_CONTROL_TABLE] Script Date: 2015/12/16 16:23:54 ******/SET ANSI_NULLS ONGOSET QUOTED_IDENTIFIER ONGOCREATE TRIGGER [TRG_VERSION_CONTROL_TABLE]ON DATABASEFOR DDL_DATABASE_LEVEL_EVENTSASSET NOCOUNT ONSET ANSI_PADDING ONIF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[VERSION_CONTROL_TABLE]') AND type in (N'U'))BEGINCREATE TABLE [dbo].[VERSION_CONTROL_TABLE]( [ID] [bigint] IDENTITY(1,1) NOT NULL, [databasename] [varchar](256) NULL, [eventtype] [varchar](50) NULL, [objectname] [varchar](256) NULL, [objecttype] [varchar](25) NULL, [sqlcommand] [nvarchar](max) NULL, [loginname] [varchar](256) NULL, [hostname] [varchar](256) NULL, [PostTime] [datetime] NULL, [Version] [int] NOT NULL, CONSTRAINT [PK_VERSION_CONTROL_TABLE] PRIMARY KEY CLUSTERED( [ID] ASC)WITH (IGNORE_DUP_KEY =OFF) ON [PRIMARY]) ON [PRIMARY]ENDDECLARE @CurrentVersion intDECLARE @CurrentID intDECLARE @DatabaseName varchar(256)DECLARE @ObjectName varchar(256)DECLARE @data XMLSET @data =EVENTDATA()INSERT INTO dbo.VERSION_CONTROL_TABLE(databasename, eventtype,objectname, objecttype, sqlcommand, loginname,Hostname,PostTime, Version)VALUES(@data.value('(/EVENT_INSTANCE/DatabaseName)[1]', 'varchar(256)'),@data.value('(/EVENT_INSTANCE/EventType)[1]', 'varchar(50)'), -- value is case-sensitive@data.value('(/EVENT_INSTANCE/ObjectName)[1]', 'varchar(256)'),@data.value('(/EVENT_INSTANCE/ObjectType)[1]', 'varchar(25)'),@data.value('(/EVENT_INSTANCE/TSQLCommand)[1]', 'nvarchar(max)'),@data.value('(/EVENT_INSTANCE/LoginName)[1]', 'varchar(256)'),HOST_NAME(),GETDATE(),0)SET @CurrentID = IDENT_CURRENT('VERSION_CONTROL_TABLE')SELECT @DatabaseName = databasename, @ObjectName = objectname FROM VERSION_CONTROL_TABLE WHERE ID = @CurrentIDIF (@DatabaseName IS NOT NULL AND @ObjectName IS NOT NULL)BEGIN SELECT @CurrentVersion = MAX(Version) FROM VERSION_CONTROL_TABLE WHERE databasename = @DatabaseName AND objectname = @ObjectName UPDATE VERSION_CONTROL_TABLE SET Version = ISNULL(@CurrentVersion, 0) + 1 WHERE ID = @CurrentIDENDSET ANSI_PADDING OFFGODISABLE TRIGGER [TRG_VERSION_CONTROL_TABLE] ON DATABASEGOENABLE TRIGGER [tr_MStran_alterschemaonly] ON DATABASEGOENABLE TRIGGER [tr_MStran_altertable] ON DATABASEGOENABLE TRIGGER [tr_MStran_altertrigger] ON DATABASEGOENABLE TRIGGER [tr_MStran_alterview] ON DATABASEGOENABLE TRIGGER [TRG_VERSION_CONTROL_TABLE] ON DATABASEGO
联系客服