Quantcast
Channel: Microsoft SQL Server
Viewing all articles
Browse latest Browse all 4871

Sql Server Trigger sending Email on row Insert

$
0
0

I received most of my info from a previous Spiceworks thread a few years ago.

It worked too well for me. The trigger decided to continuously send emails even though only 1 row was inserted.

Below, you will have my trigger and I will explain what I am tasked with. ( everyone says triggers to send email are looked down upon, but I am told this is what has got to be done )

We have a DB table that gets a row inserted when a program has an error. "ERRORTABLE"

When the row is inserted, we have a common value of 1 in a column labeled "ERRORFLAG" when the error is inserted.

We would like to send an email everytime a new row is inserted into this table.

SP SEND DBMAIL is set up and works.

What I have tried to use below is the ALTER form of the trigger that sent me 100+ emails in one minute after 1 row was inserted.

ALTER TRIGGER [dbo].[tr_ERROREMAIL]...


Viewing all articles
Browse latest Browse all 4871

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>