所以,我有一个触发器,当有人对数据库的任何表进行更改时,它会提醒我,它正在工作但突然停止了......数据库仍然能够发送电子邮件(我还有更多触发器仍在工作)并且插入我的日志表正在工作,所以,有什么想法吗?
CREATE TRIGGER [_trALterTable]
ON DATABASE
FOR ALTER_TABLE, DROP_TABLE, CREATE_TABLE
AS
DECLARE @_SUBJECT NVARCHAR(MAX);
SELECT @_SUBJECT = EVENTDATA().value('(/EVENT_INSTANCE/TSQLCommand/CommandText)[1]','nvarchar(max)')
exec msdb.dbo.sp_send_dbmail
@profile_name = 'Notifications',
@recipients = 'my.email@g.com',
@subject = @_SUBJECT,
@body = 'Changes on DB';
INSERT TriggerLog
SELECT @_SUBJECT, COALESCE(SUSER_SNAME(), USER_NAME()), GETDATE(), HOST_NAME() AS HostName;
GO