Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 Help with job

Author  Topic 

indupriyav
Starting Member

13 Posts

Posted - 2013-06-19 : 05:19:07
Hi,

Im new to SQL side programming.

The trigger code where I have to add lines for debugging calls a job as

Exec MSDB.dbo.sp_start_job @job_name = SampleJob

exec msdb.dbo.sp_help_jobstep @job_name = 'SampleJob' doesnt make sense.

It has 2 proc names in the command column. What does that mean?

Does that mean if I call SampleJob then the 2 procedures will get fired?

How can I see the content of the job?

Thanks,
Priya

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2013-06-19 : 05:24:49
yep...it means the procedures will get fired from the job

You can see content of the job visually by connecting to server in SQL Server management studio. then goto object explorer and
Expand server -> sql server agent -> jobs to see all the jobs. go to sample job right click and select properties to see properties and also each of the steps involved.

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/
https://www.facebook.com/VmBlogs
Go to Top of Page

indupriyav
Starting Member

13 Posts

Posted - 2013-06-19 : 07:17:28
Thanks. I took a look at the Job from SQLServer Agent.

It has 1 proc in Step1 of Command parameter. And another procedure in Step2 of command parameter.

So the procedure will be called one by one is it?

Suppose the Job Name is SampleJob.

It shows SampleJob in Step1's Step Name and Completed in Step2's Step Name.

Step 2 is as follows.

DECLARE @jobId BINARY(16)
------
EXEC @ReturnCode = msdb.dbo.sp_add_jobstep @job_id=@jobId, @step_name=N'Completed',
-----
@command=N'Exec My_Process',
@database_name=N'master',


* Does the Step Name 'Completed' has any significance or it is just a name for the steps.

* So the procedure in Step1 will get fired. And then proc in Step 2 namely "master.My_Process" will get executed is it?

* What is the content and significance of statement @job_id=@job_Id

Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2013-06-19 : 10:28:05
yep..the procedures will be called one after other. The second step code posted in also creating the step with exec procedure as its statement. the @job_id =@jobid will assign the correct jobid of the job to the step to indicate its a step under that job.

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/
https://www.facebook.com/VmBlogs
Go to Top of Page
   

- Advertisement -