A Database Alert Condition monitors a SQL Connection (MS SQL, MySQL or ODBC) and will Activate if a connection to the database cannot be established. You can extend this by entering a SQL Query which will be executed and the condition will be Activated based on the results. The condition will be Triggered if it stays Activated for an extended period of time (configured by you).
The Database Alert Condition window has 3 different sections working from the top of the screen to the bottom:
Section 1. The name and SQL Connection Properties
oIn the Condition Name field enter a unique name for this Alert Condition.
oClick the button to select or create a SQL Connection Profile (see SQL Connection Profiles).
oEnter the Polling Interval.
Section 2a. Activation Logic - Verify Connection Only
If you only want your Alert condition to verify that the SQL Server/Database is online then you just check the Only if the Connection Fails button and proceed to Section 3.
Section 2b. Activation Logic - Using a SQL Query
A very powerful feature in the Database Alert Condition allows you to Activate the condition based on the results of a SQL Query. To do this:
•Check the Based On Query Results button.
•Select whether your alert will be Activated based on the Field Value returned in the query OR just the Number of Rows returned in the query.
•In the Query field enter your SQL query statement (see rules below).
•Enter the RESULT logical operator. Since the results of the SQL Query will always be numeric (see Rules for SQL Queries above) enter the operator and value which Activates the condition (Greater Than 0, Less Than 1000, etc)
After entering values in Section 2a click the button to test your query.
Section 3. The Trigger Threshold
oSet the DURATION (the Trigger Threshold)
oEnable the condition by checking the Enable This Alert Condition box.
oSave your Database Alert Condition by clicking the OK button.
Troubleshooting Tip: The single most common mistake people make when using the Database Alert Condition is not properly setting up their SQL Database Connection Profile. If you opt to use the Windows Logon (Trusted) database authentication then you will likely find that you can successfully test your SQL Query in the WinScry Console software (click the button) but the WinScry Windows Service consistently fails. This is because when you are running the WinScry software from your desktop and you test your query you are running it as YOU (the user ID you used to log in to Windows) and YOU have a Trusted connection to the SQL Server, but, by default, the WinScry Windows Service runs as the built-in local computer account Local System which (most likely) does NOT have a Trusted connection to the SQL Server. This condition can be easily fixed by EITHER changing your connection profile to use MS SQL Server Security (see SQL Connection Profiles) OR by configuring the WinScry MS Windows Service to run as a domain user who DOES have a Trusted connection to the SQL Server (See Running as a User).