• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 282
  • Last Modified:

Send email when a SQL column is changed

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
sykotex
Asked:
sykotex
2 Solutions
 
Som TripathiDatabase AdministratorCommented:
Create a trigger and on update and delete. If you find the column is changed - send a mail.
0
 
rocky_lotus_newbieCommented:
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

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now