Forum Discussion
RuthlessRoth
Aug 07, 2024Copper Contributor
Trigger to send email if a table has had a INSERT, UPDATE OR DELETE
We need a trigger to be sent out if ProcessSchedule has had an INERT, UPDATE or DELETE We don't need details just a heads up type of email. The send email part is easy. EXEC msdb.dbo.sp_send...
rodgerkong
Aug 08, 2024Iron Contributor
use SQL Script below to create a trigger:
CREATE TRIGGER SendNotifyMail
ON ProcessSchedule
AFTER INSERT, UPDATE, DELETE
AS
EXEC msdb.dbo.sp_send_dbmail profile_name = 'SQLMail'
,@recipients = 'email address removed for privacy reasons'
,@body = 'Press Schedule Changed'
,@subject = 'Press Schedule Changed' ;
GO
And check out document https://learn.microsoft.com/en-us/sql/t-sql/statements/create-trigger-transact-sql?view=sql-server-ver16 for more information