Wednesday, December 23, 2009

sp_send_dbmail to send an email to representative when new lead is inserted in SQL database

A customer asked me to add this feature to his Contact management application based on SQL server 2008.
As soon as a new lead is added to the database and a representative is assigned to him or her, send an email to the representative with the contact data from the lead
This can be done from within the SQL server without any external coding required.
  • With an insert trigger the action can be started.
  • Insertion of new leads should be fast and stable, so I decided not to send the email immediately but to store the email data in a history table. The added benefit for my customer is that he can have a list of these messages to follow up with his representatives.
  • The insert trigger on the leads table inserts a new record in the history table.
  • A stored procedure is made to read new records in the history table and mail a message to the representative.
  • The stored procedure uses sp_send_dbmail.

Monday, December 21, 2009

Snow december 2009

Zondagmorgen 20 december. Vanwege de hevige sneeuwval in ons land heb ik de schop uitgehaald en ben begonnen met sneeuwruimen.

Wednesday, December 09, 2009