DEFINITIONS

Definitions More Info.
Definition ID199
TitleSQL
CategorySCRIPT
DefinitionDatabase Uzerinde Yapilan Degisiklikleri Changes Loglama1
Definition DescriptionUSE [GURMEN]
GO

/****** Object: DdlTrigger [tr_DBADatabaseChangeLog] Script Date: 19.09.2018 14:09:08 ******/
SET ANSI_NULLS ON
GO

SET QUOTED_IDENTIFIER ON
GO

CREATE TRIGGER [tr_DBADatabaseChangeLog]
ON DATABASE
FOR
CREATE_FUNCTION,
ALTER_FUNCTION,
DROP_FUNCTION,
CREATE_PROCEDURE,
ALTER_PROCEDURE,
DROP_PROCEDURE,
CREATE_INDEX,
--ALTER_INDEX,
--DROP_INDEX,
CREATE_TABLE,
ALTER_TABLE,
DROP_TABLE,
CREATE_TRIGGER,
ALTER_TRIGGER,
DROP_TRIGGER,
--CREATE_STATISTICS,
--DROP_STATISTICS,
--UPDATE_STATISTICS,
CREATE_PARTITION_FUNCTION,
ALTER_PARTITION_FUNCTION,
DROP_PARTITION_FUNCTION,
CREATE_PARTITION_SCHEME,
ALTER_PARTITION_SCHEME,
DROP_PARTITION_SCHEME,
CREATE_SCHEMA,
ALTER_SCHEMA,
DROP_SCHEMA,
CREATE_USER,
ALTER_USER,
DROP_USER,
CREATE_VIEW,
ALTER_VIEW,
DROP_VIEW,
CREATE_XML_INDEX
AS


DECLARE @data XML
DECLARE @Honame VARCHAR(100)
SET @HoName = CAST(HOST_NAME() as NVARCHAR(64))
SET @data = EVENTDATA()

INSERT INTO [DBACHECKDB].[dbo].[DBADatabaseChangeLog] (DatabaseName, EventType,ObjectName, ObjectType, SqlCommand, LoginName,HostName)
VALUES(
@data.value('(/EVENT_INSTANCE/DatabaseName)[1]', 'varchar(256)'),
@data.value('(/EVENT_INSTANCE/EventType)[1]', 'varchar(50)'),
@data.value('(/EVENT_INSTANCE/ObjectName)[1]', 'varchar(256)'),
@data.value('(/EVENT_INSTANCE/ObjectType)[1]', 'varchar(25)'),
@data.value('(/EVENT_INSTANCE/TSQLCommand)[1]', 'varchar(max)'),
@data.value('(/EVENT_INSTANCE/LoginName)[1]', 'varchar(256)'),
@Honame
)

GO

ENABLE TRIGGER [tr_DBADatabaseChangeLog] ON DATABASE
GO
RecordBycunay
Record Date22-05-2012 14:33:53
Düzenle
Kopyala
Sil