Interviewer - Server > Reference > Email component > SQL scheduling tables > SQL examples: Retrieving the user interface status and progress
 
SQL examples: Retrieving the user interface status and progress
To retrieve the count of processed records, open an ADO connection to the SendEmailHistory table and run the following query:
SELECT SUM(SuccessfulEmailCount)
FROM SendEmailHistory
WHERE Project=<Project>
  AND Job=<Job>
To retrieve the status, first ensure that the job is completely setup and the status is set to Incomplete. If the job is not setup, you can check for emails that are being sent with the following query.
SELECT ScheduledTaskId
FROM SendEmailHistory
WHERE Project=<Project>
  AND Job=<Job>
  AND BatchStatus=<Active>
Next, check if a task is scheduled by using the following query. When a record is returned, and the ScheduledTaskStatus is Completed, set the status to Schedule completed. When the ScheduledTaskStatus is Waiting, set the status to Scheduled for <datetime including time zone indicator>.
SELECT ScheduledTaskStatus, NextDueTime
FROM ScheduledTasks
WHERE Project=<Project>
  AND Job=<Job> - Requires a join to SendEmailTasks table
  ORDER BY NextDueTime
If a record is not returned, there are no tasks in progress and no scheduled tasks. In this case, set the status to Ready.
See also
SQL scheduling tables