views:

45

answers:

2

Hi All,

How can i send email if execute sql task get executed and loads a table. so, if table is loaded with any record send email, if not loaded no email.

Appreciate any help.

+4  A: 

after that task add another task that checks if there are any rows in the table

something like

IF EXISTS (SELECT 1 FROM Yourtable)
BEGIN
 EXEC msdb.dbo.sp_send_dbmail ---------
END

read up on sp_send_dbmail here: http://msdn.microsoft.com/en-us/library/ms190307.aspx

SQLMenace
Hi, thanks for your help. so i have to put recipient email address in that stored procedure?
CombatCaptain
you first need to setup db mail, start here http://msdn.microsoft.com/en-us/library/ms189684.aspx
SQLMenace
@nick: you can just store the email address in a table and query it in the procedure that sends the email
Pondlife
Hi is there any way i can do it in SSIS using control flow and data flow tasks?
CombatCaptain
A: 

its cool i solved it. i used two execute sql tasks and first one for loading data into the table, second one counting the records and i put variable on green arrow @MyVariable > 0 and connected the send mail task.

Thanks to all.

CombatCaptain