Sending mail when updating a table

My name is Tayyeb, I recently completed a course in SQL Server 2005. I am currently working as a Windows system administrator.

I am new to databases, my question is that we have a database, and if the table is updated, I would like to receive an email informing that it was updated.

Can anyone help me with this solution?

Thank you in advance

+2


source to share


3 answers


You would like to set up insert and update triggers on the table and make them call the msdb.dbo.sp_send_dbmail stored procedure.



+8


source


Create a table that stores the date and time of the last update on that particular table.

Set up a trigger for your table that updates the update date and time.



Have an external application poll the date and time at regular intervals, and if it changes, send an email.

+1


source


Trigger usage is preset. Any solution, DBMail or polling process will work. If you go to the polling process, do a polling interval that you can change while the polling process is running, if possible. The problem you will run into is that if you want to test or debug it, you don't have to wait for the full polling interval. If the interval is 5 minutes, you either need to restart the poller, or set a separate poll interval just to check if the poll interval has changed (can it be considered recursive?). So write poller with debugging / testing in mind.

This may be enough to convince you to use the DBMail solution. I have never used it so others can talk to it.

0


source







All Articles