adminbd

Записи по mssql,oracle,windows и linux

Have a Question?

If you have any question you can ask below or enter what you are looking for!

All posts tagged тригер

Триггер для sql 2005

Создаем таблицу под лог

USE [master]
GO
/****** Объект:  Table [dbo].[DDLTriggerAlterLogin]    Дата сценария: 02/25/2013 15:22:00 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[DDLTriggerAlterLogin](
	[EventType] [nvarchar](100) NULL,
	[ObjectName] [nvarchar](2000) NULL,
	[ObjectType] [nvarchar](2000) NULL,
	[LoginName] [nvarchar](max) NULL,
	[LoginType] [nvarchar](max) NULL,
	[SPID] [nvarchar](max) NULL,
	[PostTime] [datetime] NULL,
	[host] [nvarchar](128) NULL
) ON [PRIMARY]

Создаём триггер для ALTERDATABASE

/****** Object:  DdlTrigger [DDLTriggerAlterDatabase]    Script Date: 03/28/2016 10:59:50 ******/
SET ANSI_NULLS ON
GO

SET QUOTED_IDENTIFIER ON
GO


-- =============================================

-- 1) исключение срабатываний для служебной учетной записи head_offive\mssqlserver, log shipping

-- =============================================
CREATE TRIGGER [DDLTriggerAlterDatabase] ON ALL SERVER AFTER ALTER_DATABASE AS

DECLARE 
Читать далее