With nearly 15 years of "IT industry experience", I am very familiar with DML triggers, however I can't say I've seen asmuch use of DDL triggers. Still auditing new functions is a good example of how this could be useful: tighter and automatic change control is good, especially if you are concerned about hackers:
create trigger create_function_log ON DATABASE
AFTER CREATE_FUNCTION
AS DECLARE @newcode xml
SET @newcode = EVENTDATA()
INSERT INTO CreateFunctionLog (user, creation_time, code)
VALUES(CONVERT(nvarchar(100),CURRENT_USER),GETDATE(),
@newcode.value('(/EVENT_INSTANCE/TSQLCommand)[1]','nvarchar(2000)'));
No comments:
Post a Comment