Solved

Email alert when data is written to a table

Posted on 2013-10-25
4
236 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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

I have written a PowerShell script to "walk" the security structure of each SQL instance to find:         Each Login (Windows or SQL)             * Its Server Roles             * Every database to which the login is mapped             * The associated "Database User" for this …
SQL Server engine let you use a Windows account or a SQL Server account to connect to a SQL Server instance. This can be configured immediatly during the SQL Server installation or after in the Server Authentication section in the Server properties …
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.
This video explains how to create simple products associated to Magento configurable product and offers fast way of their generation with Store Manager for Magento tool.

760 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

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now