0

How to schedule a job in SQL server, when SQL Job to send an email alert if Column 'Volume' in Table 'table1' is NULL?

CR241
  • 2,293
  • 1
  • 12
  • 30
  • Have you configured a working [Database Mail Profile](https://learn.microsoft.com/en-us/sql/relational-databases/database-mail/create-a-database-mail-profile) yet? – iamdave Oct 03 '17 at 14:16

1 Answers1

0

Once you have set up a working Database Mail Profile, you can create a scheduled SQL Agent Job that on a suitable schedule executes sp_send_dbmail with your specific parameters as required.

For Example:

declare @NullCheck nvarchar(100);
set @NullCheck = (select YourColumn from YouTable);

if @NullCheck is null
execute msdb.dbo.sp_send_dbmail @profile_name = 'YourDBMailProfileName'
                               ,@recipients = 'YourEmail@Example.com'
                               ,@subject = 'Column is NULL'
                               ,@body = 'The Column is currently NULL'
iamdave
  • 12,023
  • 3
  • 24
  • 53