Solved

Send email when a SQL column is changed

Posted on 2011-03-01
2
276 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

SharePoint Admin?

Enable Your Employees To Focus On The Core With Intuitive Onscreen Guidance That is With You At The Moment of Need.

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 …
Data architecture is an important aspect in Software as a Service (SaaS) delivery model. This article is a study on the database of a single-tenant application that could be extended to support multiple tenants. The application is web-based develope…
In an interesting question (https://www.experts-exchange.com/questions/29008360/) here at Experts Exchange, a member asked how to split a single image into multiple images. The primary usage for this is to place many photographs on a flatbed scanner…
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an antispam), the admini…

739 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