SQL Server send email if no record is inserted in last hour -


I hope every record will be put per hour in the table. I want to be able to monitor that table and if the last If no record is included in the hour, an email alert should be sent to me.

What is the easiest / best solution? Batch running, monitoring device or something else?

Step 1) Create profile and account

Use the Configure Database Mail Wizard By configuring database mail node in the management node which will create profile and account, the database can be accessed from the mail context menu. This wizard account, profile and database mail is used to manage global settings

Step 2) Run

 : sp_CONFIGURE 'Advanced Show', 1GO RECONFIGURE GO Sp_CONFIGURE 'Database Mail XPs', 1 GO RECONFIGURE GO  

Step 3) Use msdb GO EXEC @ PROFILE_NAME = sp_send_dbmail 'yourprofilename', @ recipients = 'Test @ example.com', @ topic = 'test message', @ body = 'This is the body of the test message that receives the database mail successfully received by you. '

To loop through the table

  @email_id declaration NVARHCAR (450), @ ID BIGINT, @ max_id BIGINT, @queryNVARCHAR ( 1000) Select @ id = min (id), @ max_id = min (id) [email_adresses] while @ id & lt; @max_id Start Selection @ EMAIL_ID = Setting [email_adresses] from EMAIL_ID @ query = 'sp_send_dbmail @profile_name =' 'yourprofilename', @ recipient = '' '+ @ email_id +' ', @ topic =' 'test message' ', @ Body = '' This test is the body of the message. Prepares the database message you have successfully received. Exec @ Quality Selection @ id = [email_adresses] from MIN (id) where id & gt; @id END  

step 4)

Expand the SQL Server Agent node and right-click on the jobs node in SQL Server Agent and select 'New Job'

Enter the job name and a description in the 'New Job' window 'General' tab.

Select 'Step' on the left side of the window and click on 'New' below.

Enter a phase name in the 'Step' window and select the database that you want to run against the query.

Paste the T-SQL command that you want to run in the command window and click on OK.

Enter the 'schedule' menu and schedule information on the left side of the new job window (such as daily and one time).

Click 'OK' - and it should be so.

Fictional here and here


Comments

Popular posts from this blog

import - Python ImportError: No module named wmi -

Editing Python Class in Shell and SQLAlchemy -

c# - MySQL Parameterized Select Query joining tables issue -