หมายเหตุ
การเข้าถึงหน้านี้ต้องได้รับการอนุญาต คุณสามารถลอง ลงชื่อเข้าใช้หรือเปลี่ยนไดเรกทอรีได้
การเข้าถึงหน้านี้ต้องได้รับการอนุญาต คุณสามารถลองเปลี่ยนไดเรกทอรีได้
Applies to:
SQL Server
Azure SQL Managed Instance
Important
On Azure SQL Managed Instance, most, but not all SQL Server Agent features are currently supported. See Azure SQL Managed Instance T-SQL differences from SQL Server or SQL Agent job limitations in SQL Managed Instance for details.
This article describes how to stop a SQL Server Agent job. A job is a specified series of actions that SQL Server Agent performs.
Limitations
If a job is currently executing a step of type CmdExec or PowerShell, the process that is being run (for example, MyProgram.exe) is forced to end prematurely. This can cause unpredictable behavior, such as files that are being used by the process being held open.
For a multiserver job, a STOP instruction for the job is posted to all target servers of the job.
Security
For detailed information, see Implement SQL Server Agent security.
Use SQL Server Management Studio
Stop a job
In Object Explorer, connect to an instance of the SQL Server Database Engine, and then expand that instance.
Expand SQL Server Agent, expand Jobs, right-click the job you want to stop, and then select Stop Job.
If you want to stop multiple jobs, right-click Job Activity Monitor, and then select View Job Activity. In the Job Activity Monitor, select the jobs you want to stop, right-click your selection, and then select Stop Jobs.
Use Transact-SQL
In Object Explorer, connect to an instance of Database Engine.
On the Standard bar, select New Query.
Copy and paste the following example into the query window and select Execute. This example stops a job named
Weekly Sales Data Backup.USE msdb; GO EXECUTE dbo.sp_stop_job N'Weekly Sales Data Backup'; GO
For more information, see sp_stop_job.
Use SQL Server Management Objects
Call the Stop method of the Job class by using a programming language that you choose, such as Visual Basic, Visual C#, or PowerShell. For more information, see SQL Server Management Objects (SMO).