Solved

Email alert when data is written to a table

Posted on 2013-10-25
4
251 Views
Last Modified: 2013-10-25
Trying to reduce expensive developer time on our DotNetNuke website. I don't think I need to go in to the backstory so I will simply ask - is there a way I can set up an alert (email, preferably) so that I am notified whenever anything is written to a specific SQL Server database table?
0
Comment
Question by:K_Deutsch
  • 2
  • 2
4 Comments
 
LVL 19

Accepted Solution

by:
strivoli earned 500 total points
ID: 39600714
Yes. Use a trigger on INSERT or UPDATE that sends a mail to an operator using SQL's built in mail system.
0
 

Author Comment

by:K_Deutsch
ID: 39600881
I set up an email account in SQL Server Database Mail and sent a successful test email, but I need a little more direction on building the alert, as this is new to me.

Database: ABC
Table: sp_ABC_DB_OnlineFormsConfirm
0
 

Author Comment

by:K_Deutsch
ID: 39601016
Actually I am almost there. The below was successfully tested, but is there a way that in the email generated I can insert the unique ConfirmationCode that is captured so the alerted person knows what exactly to follow up on?

CREATE TRIGGER SendEmail
ON [ABC].[dbo].[ABC_DB_OnlineFormsConfirm]
AFTER INSERT
AS
exec msdb.dbo.sp_send_dbmail @profile_name = 'Gmail',
            @recipients = 'ABC@ABC-inc.com',
            @subject='An ABC Online App Has Been Completed',
            @body=''
0
 
LVL 19

Expert Comment

by:strivoli
ID: 39601353
You should be able to add any data to the mail. Even the single field values.
0

Featured Post

Optimizing Cloud Backup for Low Bandwidth

With cloud storage prices going down a growing number of SMBs start to use it for backup storage. Unfortunately, business data volume rarely fits the average Internet speed. This article provides an overview of main Internet speed challenges and reveals backup best practices.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

If you have heard of RFC822 date formats, they can be quite a challenge in SQL Server. RFC822 is an Internet standard format for email message headers, including all dates within those headers. The RFC822 protocols are available in detail at:   ht…
In this article we will get to know that how can we recover deleted data if it happens accidently. We really can recover deleted rows if we know the time when data is deleted by using the transaction log.
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…

765 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question