Send email notifcation if condition is failed

  • Hi Experts,

    How can i setup send a mail when a condition is not satisfied.

    Select count(* ) from table

    where conditions x,y,z

    if count(*) is < 1

    send mail.

    Thanks in advance

  • Declare @RecCount int

    set @RecCount = (Select count(* ) from table

    where conditions x,y,z)

    if @RecCount > 0 begin

    EXEC msdb.dbo.sp_send_dbmail

    end

  • Thank you! it helped me

Viewing 3 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic. Login to reply