?
Solved

Send email when a SQL column is changed

Posted on 2011-03-01
2
Medium Priority
?
278 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 1000 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 1000 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

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

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

Introduction This article will provide a solution for an error that might occur installing a new SQL 2005 64-bit cluster. This article will assume that you are fully prepared to complete the installation and describes the error as it occurred durin…
In SQL Server, when rows are selected from a table, does it retrieve data in the order in which it is inserted?  Many believe this is the case. Let us try to examine for ourselves with an example. To get started, use the following script, wh…
In this brief tutorial Pawel from AdRem Software explains how you can quickly find out which services are running on your network, or what are the IP addresses of servers responsible for each service. Software used is freeware NetCrunch Tools (https…
Have you created a query with information for a calendar? ... and then, abra-cadabra, the calendar is done?! I am going to show you how to make that happen. Visualize your data!  ... really see it To use the code to create a calendar from a q…

764 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