So, I have a trigger that alerts me when someone makes changes on any table of the database, It was working but suddenly it stopped... the database is still able to send emails (I have more triggers still working) and the insert into my log table is working, so, any idea?
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 = '[email protected]',
@subject = @_SUBJECT,
@body = 'Changes on DB';
INSERT TriggerLog
SELECT @_SUBJECT, COALESCE(SUSER_SNAME(), USER_NAME()), GETDATE(), HOST_NAME() AS HostName;
GO
Since inserts where happening regardless of the email being sent or not, i created another trigger after insert that sends the email, that worked, but i guess that isn't a great way of solving this issue, so, if someone has an idea please let me know