Feeds:
Posts
Comments

Posts Tagged ‘CALL SQL SERVER JOB VIA COMMAND LINE’

Script all jobs

SELECT
* FROM  msdb.dbo.SysJobs

 

 

Script all job Steps

SELECT
* FROM msdb.dbo.SysJobSteps

 

To get all steps of one Job ,say ‘Job 1’

SELECT
SJ.name AS
JobName,JB.Step_Name,JB.Step_id FROM

msdb.dbo.SysJobSteps JB

INNER
JOIN msdb.dbo.SysJobs SJ

ON
JB.job_id=SJ.job_id

WHERE
SJ.name=‘Job1’

 

Output

JobName  

Step_Name 

Step_id

Job1

Step 1

1

Job1

Step 2

2

Job1

Step 3

3

 

As shown above,’Job1′ has three steps.

 

Execute this job

EXEC msdb..sp_start_job @job_name = ‘Job1’

 

To Execute this job to start from certain step

EXEC msdb..sp_start_job @job_name = ‘Job1’, @step_name=‘Step 2’

Above can be used in “Execute SQL Task” to call job/Job Step

 

Read Full Post »

%d bloggers like this: