I have a SQL Server Agent Job that previously had two steps. Today, I've had to integrate the third step, and soon I'll need to integrate a fourth.
I want to be sure that the step will execute properly but I do not want to execute 开发者_如何转开发the entire job.
The first two steps take quite a bit of time to execute and during the day they hog a significant amount of the SQL resources that my users need.
Is there a way that I can execute a job step and not an entire job process?
Within SSMS, if I right-click on the job there is an option that states "Start Job at step..." except when I try that option it brings up a dialog that seems to imply that the entire job has been started. What can I do to test one step within a job?
Thanks in advance.
"Start job at step" will start the job at the step you specify. However - if you don't wish to execute any subsequent steps - be sure to adjust the step logic so that it will "Quit reporting success" after completing the step you started at.
In SSMS:
- Copy the code from the job step (use ctrl + a to select all)
- Paste the code in to a new query window in SSMS
- Run the code
Alternately if you have a recurring need to run just a couple steps.
Put those steps in a separate job, then kick off one job from the other to run everything. Use EXEC msdb.dbo.sp_start_job N'job_name'
You can run the short easy job on demand, and the full long job as scheduled
Use this:
EXEC msdb.dbo.sp_start_job N'job_name' , 'step_name'
Go to job properties and manually do that step. For example, there is a job with 16 steps and you want to run the 12th step, then go to that job property and see what that step 12 exactly does. If it executes a batch file in command prompt, do that manually. But this logic cannot be used in all cases.
USE [**DB_NAME**]
GO
DECLARE @return_value int
EXEC @return_value = [dbo].[**STEP_NAME**]
SELECT 'Return Value' = @return_value
GO
精彩评论