Настройка агента SQL Server 2012
Запуск службы SQL Server || Что делать если не запускается Торгсофт? (Март 2023)
Агент SQL Server позволяет автоматизировать различные административные задачи. В этом учебном пособии мы проходим процесс использования агента SQL Server для создания и планирования задания, которое автоматизирует администрирование базы данных. Это руководство относится к SQL Server 2012. Если вы используете более раннюю версию SQL Server, возможно, вам захочется прочитать «Автоматизация администрирования базы данных с помощью агента SQL Server». Если вы используете более позднюю версию SQL Server, вам может потребоваться прочитать «Настройка агента SQL Server для SQL Server 2014».
Запуск агента SQL Server в SQL Server 2012
Откройте Диспетчер конфигурации Microsoft SQL Server и нажмите на пункт «Службы SQL Server» на левой панели. Затем в правой панели найдите службу агента SQL Server. Если статус этой службы «RUNNING», вам не нужно ничего делать. В противном случае щелкните правой кнопкой мыши службу агента SQL Server и выберите «Пуск» во всплывающем меню. Затем служба начнет работать.
Переключиться на SQL Server Management Studio

Закройте диспетчер конфигурации SQL Server и откройте SQL Server Management Studio. В SSMS разверните папку агента SQL Server. Вы увидите расширенные папки, показанные выше.
Создание задания агента SQL Server

Затем щелкните правой кнопкой мыши папку «Рабочие места» и выберите «Новое задание» в начальном меню. Вы увидите окно создания нового задания, показанное выше. Заполните поле «Имя» уникальным именем для своей работы (описательный поможет вам лучше справляться с работой!). Укажите учетную запись, которую вы хотите быть владельцем задания в текстовом поле «Владелец». Задание будет выполняться с разрешениями этой учетной записи и может быть изменено только владельцем или членами роли sysadmin.
После того, как вы указали имя и владельца, в раскрывающемся списке выберите одну из предопределенных категорий работ. Например, вы можете выбрать категорию «Обслуживание базы данных» для обычных работ по техническому обслуживанию.
Используйте большое текстовое поле Описание, чтобы предоставить подробное описание цели вашей работы. Напишите его таким образом, чтобы кто-то (самостоятельно включенный!) Мог смотреть на него через несколько лет и понимать цель задания.
Наконец, убедитесь, что установлен флажок Включено.
Пока не нажимайте OK. У нас есть больше возможностей в этом окне!
Просмотр шагов работы

В левой части окна «Новое задание» вы увидите значок «Шаги» под заголовком «Выбрать страницу». Нажмите этот значок, чтобы увидеть пустой список шагов работы, показанный выше.
Создать шаг задания

Затем вам нужно будет добавить отдельные шаги для своей работы. Нажмите кнопку «Создать», чтобы создать новый шаг задания, и вы увидите окно «Новая операция», показанное выше.
Используйте текстовое поле «Имя шага», чтобы предоставить описательное имя для шага.
В раскрывающемся списке «База данных» выберите базу данных, на которую будет действовать задание.
Наконец, используйте текстовое поле Command, чтобы предоставить синтаксис Transact-SQL, соответствующий желаемому действию для этого шага задания. После того, как вы завершили ввод команды, нажмите кнопку «Анализ», чтобы проверить синтаксис.
После успешной проверки синтаксиса нажмите «ОК», чтобы создать шаг. Повторите этот процесс столько раз, сколько необходимо, чтобы определить желаемую работу агента SQL Server.
Запланируйте свой агент SQL Server Agent 2012

Наконец, вы захотите установить расписание для задания, щелкнув значок «Расписание» в разделе «Выбрать страницу» окна «Новое задание». Вы увидите окно нового расписания работы, показанное выше.
Укажите имя расписания в текстовом поле «Имя» и выберите тип расписания (одноразовый, повторяющийся, «Старт, когда агент SQL Server запускается или запускается, когда CPU становятся бездействующими») из раскрывающегося списка. Затем используйте разделы частоты и продолжительности окна, чтобы указать параметры задания. Когда вы закончите, нажмите «ОК», чтобы закрыть окно «Расписание» и «ОК», чтобы создать задание.
Создание оповещения с помощью агента SQL Server
Механизм предупреждения обеспечивает 24-часовой мониторинг производительности базы данных SQL Server без штатного круглосуточного операционного центра.
Создание следов с помощью SQL Server 2012 и SQL Profiler

С помощью инструмента диагностики SQL Profiler в Microsoft SQL Server вы создаете трассировки SQL, отслеживающие конкретные действия, выполняемые с базой данных SQL Server.
Автоматизация администрирования базы данных с помощью агента SQL Server

Агент SQL Server позволяет создавать и планировать задание, которое автоматизирует администрирование базы данных.
Enable SQL Server Agent via SSMS
If you were trying to create a SQL Server Agent job for the first time, but a message popped up that confused you, read on.
There are a couple of reasons you could get such a message.
- The SQL Server Agent service is currently stopped (and needs to be started)
- The SQL Server Agent extended procedures (Agent XPs) are currently disabled (and need to be enabled)
Either way, it’s normally quite a quick and easy process to enable Agent XPs and/or start the SQL Server Agent.
Example
Here’s an example of the popups and screens that you might encounter when enabling the Agent XPs and starting the SQL Server Agent service.

We can see just by looking at this screenshot that Agent XPs are disabled.
Right click on SQL Server Agent (Agent XPs disabled) to bring up the following contextual menu:

Click Start.
You may be presented with the following dialog box:

Click Yes to allow the app to make changes to your device.
This brings us to the following prompt:

Click Yes to start the SQL Server Agent service.
That should do it.
You may need to refresh the Object Explorer to see the effect. To do this, right click on SQL Server Agent (Agent XPs disabled) to open the contextual menu:

Click Refresh.
If the SQL Server Agent is running, you should see the green icon next to it, like this:

If you find that Agent XPs are still disabled, perhaps try the T-SQL method.
Name already in use
sql-docs / docs / database-engine / configure-windows / start-stop-pause-resume-restart-sql-server-services.md
- Go to file T
- Go to line L
- Copy path
- Copy permalink
- Open with Desktop
- View raw
- Copy raw contents Copy raw contents
Copy raw contents
Copy raw contents
Start, stop, pause, resume, and restart SQL Server services
This article describes how to start, stop, pause, resume, or restart the [!INCLUDEssNoVersion] [!INCLUDEssDE], the SQL Server Agent, or the SQL Server Browser service on Windows by using SQL Server Configuration Manager, SQL Server Management Studio (SSMS), net commands from a command prompt, Transact-SQL, or PowerShell.
Identify the service
[!INCLUDEssNoVersion] components are executable programs that run as Windows services. Windows services can run without displaying any activity on the computer screen and without user interaction on the command line.
Database Engine service
The [!INCLUDEssDE] service can be the default instance (limit one per computer) or can be one of many named instances on the computer. Use SQL Server Configuration Manager to find out which instances of the [!INCLUDEssDE] are installed on the computer. The default instance (if you install it) is listed as SQL Server (MSSQLSERVER). Named instances (if you install them) are listed as SQL Server (<instance_name>). By default, [!INCLUDEssNoVersion] is installed as SQL Server (SQLEXPRESS).
SQL Server Agent service
The SQL Server Agent service executes scheduled administrative tasks, which are called jobs and alerts. For more information, see SQL Server Agent. SQL Server Agent isn’t available in every edition of [!INCLUDEssNoVersion]. For a list of features that are supported by the editions of [!INCLUDEssNoVersion], see Features Supported by the Editions of SQL Server 2019.
SQL Server Browser service
The SQL Server Browser service listens for incoming requests for [!INCLUDEssNoVersion] resources and provides clients information about [!INCLUDEssNoVersion] instances installed on the computer. A single instance of the SQL Server Browser service is used by all instances of [!INCLUDEssNoVersion] installed on the computer.
If you pause the [!INCLUDEssDE] service, users who are already connected can continue to work until their connections are broken, but new users can’t connect to the [!INCLUDEssDE]. Use Pause when you want to wait for users to complete their work before you stop the service, which lets them complete transactions that are in progress. Resume allows the [!INCLUDEssDE] to accept new connections again. The SQL Server Agent service can’t be paused or resumed.
The SQL Server Configuration Manager and SSMS display the current status of services by using the following icons.
You won’t have access to all possible options when using SQL Server Configuration Manager or SSMS, depending on the state of the service. For example, if the service is already started, Start is unavailable.
When running on a cluster, the [!INCLUDEssNoVersion] [!INCLUDEssDE] service is best managed by using Cluster Administrator.
By default, only members of the local administrator group can start, stop, pause, resume, or restart a service. To grant non-administrators the ability to manage services, see How to grant users rights to manage services in Windows Server 2003. (The process is similar on other versions of Windows Server.)
Stopping the [!INCLUDEssDE] by using the Transact-SQL SHUTDOWN command requires membership in the sysadmin or serveradmin fixed server roles, and isn’t transferable.
SQL Server Configuration Manager
Start SQL Server Configuration Manager
On the Start menu, select All Programs > Microsoft SQL Server > Configuration Tools > SQL Server Configuration Manager.
The SQL Server Configuration Manager is a snap-in for the Microsoft Management Console program, and it may not appear as an application in some versions of Windows. For more information, see SQL Server Configuration Manager.
Start, stop, pause, resume, or restart an instance of the SQL Server Database Engine
Start SQL Server Configuration Manager, using the instructions in the previous section.
If the User Account Control dialog box appears, select Yes.
In SQL Server Configuration Manager, in the left pane, select SQL Server Services.
In the results pane, right-click SQL Server (MSSQLServer) or a named instance, and then select Start, Stop, Pause, Resume, or Restart.
Select OK to close the SQL Server Configuration Manager.
[!IMPORTANT]
Starting with [!INCLUDE sssql22-md], when you set the Start Mode for a [!INCLUDE ssnoversion-md] service to Automatic in Configuration Manager, the service will start in Automatic (Delayed Start) mode instead, even though the Start Mode shows as Automatic.
Start, stop, pause, resume, or restart the SQL Server Browser or an instance of the SQL Server Agent
Start SQL Server Configuration Manager, using the instructions in the previous section.
If the User Account Control dialog box appears, select Yes.
In SQL Server Configuration Manager, in the left pane, select SQL Server Services.
In the results pane, right-click SQL Server Browser, or SQL Server Agent (MSSQLServer) or SQL Server Agent (<instance_name>) for a named instance, and then select Start, Stop, Pause, Resume, or Restart.
Select OK to close the SQL Server Configuration Manager.
[!NOTE]
SQL Server Agent can’t be paused.
SQL Server Management Studio
Start, stop, pause, resume, or restart an instance of the Database Engine
In Object Explorer, connect to the instance of the [!INCLUDEssDE], right-click the instance of the [!INCLUDEssDE] you want to start, and then select Start, Stop, Pause, Resume, or Restart.
Or, in Registered Servers, right-click the instance of the [!INCLUDEssDE] you want to start, point to Service Control, and then select Start, Stop, Pause, Resume, or Restart.
If the User Account Control dialog box appears, select Yes.
When prompted if you want to act, select Yes.
Start, stop, or restart an instance of the SQL Server Agent
In Object Explorer, connect to the instance of the [!INCLUDEssDE], right-click SQL Server Agent, and then select Start, Stop, or Restart.
If the User Account Control dialog box appears, select Yes.
When prompted if you want to act, select Yes.
Command Prompt window using net commands
The [!INCLUDEssNoVersion] services can be started, stopped, or paused by using Windows net commands.
Start the default instance of the Database Engine
From a command prompt, enter one of the following commands:
Start a named instance of the Database Engine
From a command prompt, enter one of the following commands. Replace <instancename> with the name of the instance you want to manage.
Start the Database Engine with startup options
Add startup options to the end of the net start «SQL Server (MSSQLSERVER)» statement, separated by a space. When started using net start, startup options use a slash (/) instead of a hyphen (-).
Start the SQL Server Agent on the default instance of [!INCLUDEssNoVersion]
From a command prompt, enter one of the following commands:
Start the SQL Server Agent on a named instance of [!INCLUDEssNoVersion]
From a command prompt, enter one of the following commands. Replace instancename with the name of the instance you want to manage.
For information about how to run SQL Server Agent in verbose mode for troubleshooting, see sqlagent90 Application.
Start the SQL Server Browser
From a command prompt, enter one of the following commands:
Pause or stop services from the command prompt window
To pause or stop services, modify the commands in the following ways.
To pause a service, replace net start with net pause.
To stop a service, replace net start with net stop.
The [!INCLUDEssDE] can be stopped by using the SHUTDOWN statement.
Stop the Database Engine using Transact-SQL
To wait for currently running Transact-SQL statements and stored procedures to finish, and then stop the [!INCLUDEssDE], execute the following statement.
To stop the [!INCLUDEssDE] immediately, execute the following statement.
For more information about the SHUTDOWN statement, see SHUTDOWN (Transact-SQL).
Start and stop Database Engine services
In a Command Prompt window, start [!INCLUDEssNoVersion] PowerShell by executing the following command.
At a [!INCLUDEssNoVersion] PowerShell command prompt, by executing the following command. Replace computername with the name of your computer.
Identify the service that you want to stop or start. Pick one of the following lines. Replace instancename with the name of the named instance.
To get a reference to the default instance of the [!INCLUDEssDE].
To get a reference to a named instance of the [!INCLUDEssDE].
To get a reference to the SQL Server Agent service on the default instance of the [!INCLUDEssDE].
To get a reference to the SQL Server Agent service on a named instance of the [!INCLUDEssDE].
To get a reference to the SQL Server Browser service.
Complete the example to start and then stop the selected service.
Check and enable disabled instances
To determine whether a SQL Server service instance is disabled, follow these steps:
Identify the service that you’re trying to check by using the information in the Identify the Service section.
In SQL Server Configuration Manager, select SQL Server Services and then locate the service you’re interested in.
If the value of the Start Mode column is set to Other (Boot, System, Disabled or Unknown), it typically means the corresponding service is disabled. To enable the service, follow these steps:
a. In the Name column, right-click on the corresponding service and then switch to Service tab in the <Service name> Properties window.
b. Review the value in the Start Mode column and verify that it’s set to Disabled.
c. Change the value to either Manual or Automatic per your requirements. For more information, see Configure Server Startup Options (SQL Server Configuration Manager).
Use the ServiceController class
You can use the ServiceController class to programmatically control the [!INCLUDEssNoVersion] service, or any other Windows service. For an example using C#, see ServiceController Class.
Getting Started with SQL Server Agent — Part 1
I am a SQL Server Developer who recently migrated to a team with data integration production and monitoring functions. Everybody on the team uses SQL Server Agent, but I have practically no hands-on experience with it. Please give me a quick tutorial on creating a job, adding a schedule, and monitoring the operation of SQL Server Agent Jobs.
Solution
One especially fast way to ramp up to speed with SQL Server Agent is to use the Jobs and Jobs Activity Monitor icons under SQL Server Agent in Object Explorer within SQL Server Management Studio (SSMS). These icons open options for manually creating, configuring, controlling the operation of, and monitoring SQL Server Agent Jobs. While it is useful to program SQL Server Agent Jobs, it is not necessary to start deriving much value from it — especially during your initial introduction to it.
The tips covered here will focus on how to create and run SQL Server Agent Jobs. SQL Server Agent Jobs can be invoked on demand or on a schedule. You will initially learn about running a job on demand and later about how to assign a schedule to the job. The tip will also demonstrate how two SQL Server Agent Jobs can complement one another to satisfy a reporting requirement.
One of the most valuable manual features of SQL Server Agent is its Activity Monitor. You can use this feature to view the current status of a job as well as their past and prospective future performance on a SQL Server instance. This tip demonstrates selected menus from the Activity Monitor environment.
Creating your first two SQL Server Agent Jobs
To run a job on demand means the job has no schedule or is being run independent of the schedule. For example, you have to specifically invoke the job each time that you want it to run. One of the main advantages of SQL Server Agent is that it can schedule SQL Server Agent jobs. A job can be as simple as a T-SQL script. All the examples in this tip run T-SQL scripts. The first script creates a table in a database. The second script inserts a row into the table. By running the second job, we will be able to add a row to the table created in the first script.
To start your first SQL Server Agent job, open Object Explorer in SSMS and verify SQL Server Agent is running. The SQL Server Agent icon is available at the same level as the Databases icon. While Databases is the top icon underneath the Server icon in Object Explorer, SQL Server Agent is the last icon at the Databases level underneath the Server icon.
If the team to which you belong is regularly using SQL Server Agent, the feature will be on. However, if it is not on, you can right click the SQL Server Agent icon and choose Start. A green arrowhead next to the icon will indicate that it is on.
Right below the SQL Server Agent icon is the Jobs icon. You can use this icon to start a new job. Every job must have a name and at least one job step. All the jobs in this tip will have just one step. In the screen shot below, you see the SQL Server Agent icon and the Jobs folder below it.

Right click the Jobs folder and choose New Job to start a new job. This opens the New Job dialog. You can use this dialog to assign a name to the job. Additionally, you can add descriptive text about the job. See a completed example below of a New Job dialog with a name and description for a job.

Click the Steps page within the New Job dialog to present a dialog for adding a step to the job. Each step within a job designates what the step does. As with each job, every step within a job must have a name. Click the New button on the Steps page to assign a name to a step and indicate what the job step should do.
The following screen shot shows a completed Steps page. Notice that both the Step name and Command boxes have entries. The step name can reflect the role of the step. If you are using T-SQL to designate what the step should do, you can type or paste you code into the Command box. The code in the screen shot below assumes the prior creation of a database named for_SQL_Server_Agent_jobs. The code creates a fresh version of a table named RecordsNumericandDateTimeValues in the for_SQL_Server_Agent_jobs database.

The next two screen shots show key dialog boxes for creating a new job named Insert a value in a table. The table name is RecordsNumericandDatetimeValues in the for_SQL_Server_Agent_jobs database. The job has just one step that inserts 1 into the number_value column and the current datetime value into the date column of the table.


Run SQL Server Agent Jobs and Diagnose Performance
You can attempt to run a job by opening Job Activity Monitor with a View Job Activity menu selection, selecting the job, and invoking the Start Job at Step command from the context menu. The following screen shot shows the Job Activity Monitor just prior to the invoking of the Start Job at Step command for the Create a table job. The command will create a fresh copy of the RecordsNumericandDateTimeValues table in the for_SQL_Server_Agent_jobs database.

Next, we can invoke the Insert a value in a table job by selecting this job instead of the Create a table job. After successfully invoking both jobs, the RecordsNumericandDateTimeValues table will have one row in it that reflects the date and time when an insert was performed. The following screen shot shows a query and result set confirming the addition of one row to the RecordsNumericandDateTimeValues table.

It is possible for jobs in a production environment to fail for any of a variety of reasons. In the context of our example, the Insert a value in a table job can fail if the RecordsNumericandDateTimeValues table is dropped after the Create a table job is run and before the Insert a value in a table job is run. This can happen if some administrator or process inadvertently drops the table in the for_SQL_Server_Agent_jobs database. To show you how to diagnose a run-time failure, the RecordsNumericandDateTimeValues table was purposely dropped.
The following screen shot shows the outcome of trying to run the Insert a value in a table job when the the RecordsNumericandDateTimeValues table does not exist. Notice that an error is reported, but you are referred to the history log for additional details.

You can show the history log for a job step with two successive commands. First, select the job in Job Activity Monitor. Complete the first step by choosing the View history command from the context menu. The following screen shot shows the view just before invoking the View history command.

The second step involves selecting the job step with the failure in Log File Viewer. From this viewer, you can examine the message describing the error. In our example, the Message indicates the job failed because of an invalid object named RecordsNumericandDateTimeValues. Recall that the table with this name was manually dropped prior to invoking the Insert a value in a table job.

Adding a job with a schedule
Recall that one of the main advantages of SQL Server Agent is that it can run a job on a schedule. This section introduces you to the basics of adding a job that runs on a schedule.
Choose New Job from Jobs icon under SQL Server Agent. Assign a name to the job and optionally a description. The following screen shot shows the entry for a new job named Insert a value in a table with a schedule. A brief description is also assigned.

Next, select the Steps page. Click New towards the bottom of the page. Populate the Step name and Command boxes on the New Job Step page as indicated below. Then, click OK.

Next, select the Schedules page for the job. Then, click New.
- In the Name box type: Run daily every 5 minutes
- In the Schedule type drop-down box select Recurring
- In the Frequency settings,
- Choose Daily for the Occurs drop-down box and
- Enter 1 day(s) for Recurs every
- Choose the Occurs every radio button
- Enter a value of 5 and
- Select a value of minute(s) from the drop-down box
After completing the settings, click OK to enable the schedule for the job. Then, click OK to save all the settings for the job named Insert a value in a table with a schedule. These settings will create a job that inserts a value of 1 in the RecordsNumericandDateTimeValues table every 5 minutes throughout each day. The job runs every day of the week because of the settings in the Frequency settings of the schedule page. Because SQL Server Agent is a SQL Server feature, the execution of the schedule for a job depends on the SQL Server instance for a SQL Server Agent being operational.

Running a SQL Server Agent Job with a Schedule
The job created with the preceding steps cannot run unless there is a RecordsNumericandDateTimeValues table in the for_SQL_Server_Agent_jobs database. Because this table is currently deleted, you must invoke the Create a table job before launching the Insert a value in a table with a schedule job. You can invoke the Create a table job from Activity Monitor by selecting the job and choosing Start Job at Step.
Next, you can select the Insert a value in a table with a schedule job in Activity Monitor and invoke it in the same way. This will cause the job to run indefinitely unless a menu selection stops the job, some error condition is encountered, or the server suspends operation for any reason. Recall that the job runs every 5 minutes of every day. At some point in the future, you can validate the operation of the job. For example, you can select all the rows in the RecordsNumericandDateTimeValues table.
To demonstrate the operation of the job, it was invoked on April 9, 2017 at around 7:08 PM. The query and screen shot below with a result set for the first 14 executions of the job appear below.
- The first record inserted into the newly created RecordsNumericandDateTimeValues table was at 19:08 hours on April 9, 2017; hours are represented on a 24-hour per day basis.
- A second record was inserted just after 19:10 hours, the commencement of the first 5-minute interval within an hour after 19:08.
- About every 5 minutes to within milliseconds, an additional record is inserted into the table.

Creating a job to summarize the outcome from another job
While it may sometimes be helpful to see the results for each operation of a job, it is also valuable to obtain a more summarized view of how an application is working. The next example illustrates how to provide this kind of capability with a new table and a new job. Instead of viewing the outcomes from the Insert a value in a table with a schedule job for each 5-minute interval, we can count the entries in the RecordsNumericandDateTimeValues table for each day. For example, the following query counts the number of rows entered into the table on each day.
Assume that a requirement is issued for this kind of summary information. The requirement is for summary information being updated through midnight on each day. A SQL Server Agent job can automate the implementation of this capability through a scheduled job.
First, we need a new table into which to save the summary information. The following screen shot displays the sole job step for the Create a summary table job. As you can see, the job step’s name is Create a fresh summary table. The T-SQL in the command box performs these functions.
- Switch context from the default master database context to the for_SQL_Server_Agent_jobs database.
- Drop any previously existing version of the InsertsPerDay table in the database if one exists.
- Create a fresh version of the InsertsPerDay table with two columns: one named date and a second named Number of Inserts.
- Finally, the job step code specifies a primary clustered index on the date column. This is appropriate because the table is meant to have just one row per date value with the number of inserts for the date value on a row.
This Create a summary table job does not have a schedule. It is designed to operate on demand whenever there is the need to create a fresh copy of the InsertsPerDay table in the for_SQL_Server_Agent_jobs database.

The next screen shot shows the Freshly populate the InsertsPerDay table job step dialog from the Populate the InsertsPerDay table job. This job uses a different approach to reference a table in a job step than previously covered job steps. Instead of switching the context from the master database to the for_SQL_Server_Agent_jobs database, the code leaves the default database context to its default value of the master database. References to tables include a database name qualifier pointing at the for_SQL_Server_Agent_jobs database.
The job step has just two purposes.
- It initially truncates the InsertsPerDay table in the dbo schema of the for_SQL_Server_Agent_jobs database.
- Next, the job step uses an INSERT statement to populate the InsertsPerDay table with the result set from a query that counts the number of inserts per date value for all rows in the RecordsNumericandDateTimeValues table. These inserts are originally generated by the Insert a value in a table with a schedule job; see the Adding a job with a schedule section above to review this job.

In order for the Populate the InsertsPerDay table job to refresh the InsertsPerDay table at midnight on each day, you can specify a schedule like the one displayed in the screen shot below. The schedule name for this job is Daily at midnight. This schedule can be added to the Populate the InsertsPerDay table job in the same way that a schedule was added to the Insert a value in a table with a schedule job.
Notice that the job operates every one day just like the schedule for the Run daily every 5 minutes schedule for the job step in the Insert a value in a table with schedule job. However, one important difference is that this second schedule operates just once per day at midnight (12:00 AM).

Validating the Create a summary table job over three days
The Create a summary table job populates the InsertsPerDay table with the number of inserts on a daily basis into the RecordsNumericandDateTimeValues table. Recall that the Insert a value in a table with a schedule job populates the RecordsNumericandDateTimeValues table. A test run of these two jobs was conducted starting on 2017-04-09 19:08:21.340 and ending on 2017-04-12 03:30:00.990. Over this time span, there are three midnights (00:00:00.000) — one each on April 9, 10, and 11. An exogenous event caused the computer to halt operation after the last insert into the RecordsNumericandDateTimeValues table at 2017-04-12 03:30:00.990.
The following query returns the contents in the InsertsPerDay table for dates from 2017-04-09 through 2017-04-11. The following screen presents the result set from the query. The number of inserts on the tenth and eleventh of April cover 24-hour periods. Notice there are 288 inserts on each of these days. Within a 24-hour period, there are 288 5-minute intervals (12 per hour times 24 hours).

Another way of validating the results is to count independently the rows per day in the RecordsNumericandDateTimeValues table for each day from 2017-04-09 through 2017-04-11. The following three queries show the independent query for each day from 2017-04-09 through 2017-04-11. The screen shot below the query listings display the three corresponding result sets. Notice that the count for each day independently from the RecordsNumericandDateTimeValues table match exactly the values from the InsertsPerDay query.