SQL Server Forums
Profile | Register | Active Topics | Members | Search | Forum FAQ
 
Register Now and get your question answered!
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 Help with job
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

indupriyav
Starting Member

India
13 Posts

Posted - 06/19/2013 :  05:19:07  Show Profile  Reply with Quote
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

India
52249 Posts

Posted - 06/19/2013 :  05:24:49  Show Profile  Reply with Quote
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

India
13 Posts

Posted - 06/19/2013 :  07:17:28  Show Profile  Reply with Quote
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


Edited by - indupriyav on 06/19/2013 08:20:04
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

India
52249 Posts

Posted - 06/19/2013 :  10:28:05  Show Profile  Reply with Quote
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
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
SQL Server Forums © 2000-2009 SQLTeam Publishing, LLC Go To Top Of Page
This page was generated in 0.06 seconds. Powered By: Snitz Forums 2000