September 13, 2011 at 5:38 am
I would like to create a job for
SELECT datediff(n, dc_date ,last_start_date) FROM PARM
if the output is more than 10 mins i would like to send an email.
I looked into creating a SQL job but there is no place where i can specify IF statement for the output from SQL Statement.
September 13, 2011 at 5:44 am
Well yes you can.
If ()
begin
sp_send_dbmail
end
Schedule that to run every x minutes and you're on your way.
September 13, 2011 at 6:14 am
i'd code it with an EXISTS like this:
IF EXISTS(SELECT 1
FROM PARM
WHERE datediff(n, dc_date ,last_start_date) > 10)
BEGIN
--do stuff here
PRINT 'Sending emails'
END
Lowell
Viewing 3 posts - 1 through 3 (of 3 total)
You must be logged in to reply to this topic. Login to reply