This article is a mirror article of machine translation, please click here to jump to the original article.

View: 12448|Reply: 1

[Source] SQL Server jobs

[Copy link]
Posted on 9/5/2018 4:58:19 PM | | | |
This post was last edited by sgFengSu on 2018-9-6 08:51

Whether it's a database or another system, there will be something that can be executed without human involvement.
This kind of definition can be achieved through jobs in the SQL Server database.
For SQL SERVER jobs, it is a series of specified operations performed sequentially by the SQL SERVER agent.

The main one related to the job is the job as shown in the following diagram, and the other is the job activity monitor (SQL Server proxy service needs to be enabled)



After the basic preparation is completed, the next step is to create, execute, modify, and delete the job

sp_add_job
Create a job
sp_add_jobstep
Create one or more job steps
sp_add_schedule
Create a plan
sp_attach_schedule
Attach a plan to an activity
sp_add_jobserver
Set the server for the job
Of course, I personally find the friendly view much faster than executing these statements (achieved by right-clicking on the job - creating the job)


In the step, I personally prefer to write the statement to be executed as a stored procedure, and it is more convenient to only maintain the stored procedure later

When creating a new step, you may encounter this situation as shown in the figure below, because the component in the last parentheses is missing, you can refer to the link
https://www.cnblogs.com/lhp-net/archive/2013/01/22/2871462.html


In the plan, try to add a plan to send an email to the administrator if it fails, so as to avoid the situation that you don't know if the job execution fails, and some antivirus software will also block this job, if there is an antivirus engine, try to add a whitelist.

Tip, some stored procedures may be executed for more than a minute, this kind of execution on the page, the page will have a response timeout mechanism, and then report some errors, and the stored procedure cannot be executed.
If this happens, the stored procedure is really impossible to optimize, and the stored procedure can be placed in the job to execute the jobexecmsdb.dbo.sp_start_job@job_name='job_name'In this way, embarrassment can be avoided, and of course don't forget to remind the end of the execution.
exec msdb.dbo.sp_start_job @job_name='job_name'







Previous:Understanding of the instanceof keyword in Java
Next:Spring and MyBatis integrate the text type pit in the automatically generated code
Posted on 9/6/2018 9:27:51 AM |
Procedure for the daily automatic backup operation of SQL Server databases
https://www.itsvse.com/thread-4895-1-1.html
(Source: Architect_Programmer)
Disclaimer:
All software, programming materials or articles published by Code Farmer Network are only for learning and research purposes; The above content shall not be used for commercial or illegal purposes, otherwise, users shall bear all consequences. The information on this site comes from the Internet, and copyright disputes have nothing to do with this site. You must completely delete the above content from your computer within 24 hours of downloading. If you like the program, please support genuine software, purchase registration, and get better genuine services. If there is any infringement, please contact us by email.

Mail To:help@itsvse.com