Link to home
Start Free TrialLog in
Avatar of Fordraiders
FordraidersFlag for United States of America

asked on

send an email if an insert statement from staging table records do not match the master table

sql server 2008 r2

I have a job that runs every night.
In the sql , I need some type of email alert that will tell me if after an "insert statement" was completed;
If the records that were in a staging table has the same count as in my master table ?

I cant find any code reference to my  question ?

Thanks
fordraiders
ASKER CERTIFIED SOLUTION
Avatar of Ryan Chong
Ryan Chong
Flag of Singapore image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Step 1: Enhance your job (procedures behind), so that you log this information into a separate table.
Step 2: Use sp_send_dbmail as Ryan wrote in a separate job scheduled later to collect information from your log to generate and send that e-mail.

Advantage: You can collect information about more then the ETL job to provide an summary e-mail of your daily system state as a single e-mail.

Important thing here: You must send the e-mail every day, even when there is nothing to report. Otherwise you would not notice a system failure.
Avatar of Fordraiders

ASKER

thanks !!