0

Daily around thousands of entries would be added. I believe we can write a inserted trigger but is it advisable or if you can suggest another way to do so? It should send mail to an email field in the database for that row once its added to the table. There will be thousands of records daily.

Nikhil
  • 31
  • 1
  • 7
  • 2
    I'm assuming you have a periodic task that sends emails to all new entries. Why not add a bit that is inserted as 0, and when the email is sent the task sets the bit to 1? The selection process from the SQL table becomes trivial. – Blue Granny Dec 16 '19 at 05:32
  • Yea we can do that.But how to do it?By exec sp_send_mail? I have thousands of record daily. Wont it be a problem? @ArikRinberg – Nikhil Dec 16 '19 at 06:07
  • trial and error? Run a test and see how long it takes. You can create and time 10 emails to see how long an email takes, and then test with sleep. Worst case scenario run the task more frequently. – Blue Granny Dec 16 '19 at 06:15
  • ok so you are saying using an inserted trigger send mails? @ArikRinberg – Nikhil Dec 16 '19 at 06:32
  • Yeah, I think that's what I would try – Blue Granny Dec 16 '19 at 09:29

1 Answers1

0

Probably this answer will help you setting the sendmail trigger. In that answer it is also suggested an alternative: populate a queue table and use a background task for sending the email. According to me, the latter is the best way. Pay attention, sending thousands emails every day can expose your server to be blacklisted.

Ad Fortia
  • 333
  • 1
  • 3
  • 12