Solved

Send email when a SQL column is changed

Posted on 2011-03-01
2
272 Views
Last Modified: 2012-06-21
Hi
I have a sql 2005 table with a column names pin_number how do I generate an email or alert whenever this field is deleted or updated?
0
Comment
Question by:sykotex
2 Comments
 
LVL 8

Accepted Solution

by:
Som Tripathi earned 250 total points
ID: 35010403
Create a trigger and on update and delete. If you find the column is changed - send a mail.
0
 
LVL 4

Assisted Solution

by:rocky_lotus_newbie
rocky_lotus_newbie earned 250 total points
ID: 35011792
The Below Artticle has the details of how to configure the Database Mail in SQL 2008.

http://blog.sqlauthority.com/2008/08/23/sql-server-2008-configure-database-mail-send-email-from-sql-database/


Once you set it up:

Include the Below command in the DELETE/UPDATE Trigger to send an email to the desired email id.


USE msdb
GO
EXEC sp_send_dbmail @profile_name='PinalProfile',
@recipients='test@Example.com',
@subject='Test message',
@query = 'select * from table where condition=''YES'''
@body='This is the body of the test message.
Congrates Database Mail Received By you Successfully.',
@attach_query_result_as_file = 0,
@query_result_width=5000


This link has the syntax for sample Delete/Update trigger:

http://www.kodyaz.com/articles/sql-trigger-example-in-sql-server-2008.aspx


Thanks,
0

Featured Post

Comprehensive Backup Solutions for Microsoft

Acronis protects the complete Microsoft technology stack: Windows Server, Windows PC, laptop and Surface data; Microsoft business applications; Microsoft Hyper-V; Azure VMs; Microsoft Windows Server 2016; Microsoft Exchange 2016 and SQL Server 2016.

Question has a verified solution.

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

When writing XML code a very difficult part is when we like to remove all the elements or attributes from the XML that have no data. I would like to share a set of recursive MSSQL stored procedures that I have made to remove those elements from …
In this article I will describe the Copy Database Wizard method as one possible migration process and I will add the extra tasks needed for an upgrade when and where is applied so it will cover all.
This Micro Tutorial will give you a basic overview how to record your screen with Microsoft Expression Encoder. This program is still free and open for the public to download. This will be demonstrated using Microsoft Expression Encoder 4.
Both in life and business – not all partnerships are created equal. As the demand for cloud services increases, so do the number of self-proclaimed cloud partners. Asking the right questions up front in the partnership, will enable both parties …

911 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

15 Experts available now in Live!

Get 1:1 Help Now