I would like to send an e-mail alert after inserting a new data to my sql server data table. How can i do this?
I have tried following trigger, but i'm no pretty sure about the functionality of it.
CREATE TRIGGER dbo.sendMail
ON dbo.staff_leaves
AFTER INSERT
AS
BEGIN
SET NOCOUNT ON;
EXEC msdb.dbo.sp_send_dbmail
@to = 'whoever@yourcompany.com',
@profile_name = 'default',
@subject = 'New Row',
@body = 'Yep, they sure were.';
END
GO
Anyone please explain me how to do this.