Getting Job name, Job ID , Step within the Job

Getting Job name, Job ID , Step within the Job

Post by U2hpbn » Wed, 21 Dec 2005 19:47:01


Hi There,

Can I get the Job ID , Job name and Step ID withing the job itself ? Infact
my need is to send a mail with these parameters and some data from user
tables. This process I have to do from the different servers and jobs. I
would like to impliment this without hardcoding the job names , Job ID etc.

Thank you,

Shinu
 
 
 

Getting Job name, Job ID , Step within the Job

Post by TUw » Wed, 21 Dec 2005 20:08:03

Please post DDL, sample data and expected result. If I understand your
question correctly, then I see no reason why this question would ever need to
be asked.


ML

---
http://www.yqcomputer.com/

 
 
 

Getting Job name, Job ID , Step within the Job

Post by U2hpbn » Wed, 21 Dec 2005 20:33:02

Hi ,

Thank you

I just want to get the name of the Job and Job ID within a step of the same
job and mail it.

Eg: In step 1 of the job1 I need to send a mail
EXEC msdb.dbo.SP_Send_DBMail @Profile_Name = 'MyProfile',
@Recipients = ' XXXX@XXXXX.COM ',
@Body = @job,
@Subject = @@Servername

Regards,

Shinu
 
 
 

Getting Job name, Job ID , Step within the Job

Post by TUw » Wed, 21 Dec 2005 20:47:01

To put it as simple as possible: concatenate the values you want to send in
the body of the e-mail message into a single varchar variable or use the
@query parameter to specify a query whose result set can either be sent as an
attachment or a part of the body.


ML

---
http://www.yqcomputer.com/
 
 
 

Getting Job name, Job ID , Step within the Job

Post by U2hpbn » Wed, 21 Dec 2005 20:51:02

Hi ,

How can I get the jobname and Job ID within the job ?

Thanks

Shinu
 
 
 

Getting Job name, Job ID , Step within the Job

Post by TUw » Wed, 21 Dec 2005 21:03:02

What exactly are you trying to achieve? Are you designing a procedure that
will send messages as SQL Server Jobs are being run, that can be used in
several of your jobs?

Look at the sysjobs system table (in the msdb database).


ML

---
http://www.yqcomputer.com/
 
 
 

Getting Job name, Job ID , Step within the Job

Post by Tibor Kara » Wed, 21 Dec 2005 21:37:11

My guess is that Shinu want to receive an email with the name of the job, whether the job was OK,
the ID of the job etc. I do this all the time.

Shinu, you can use Agent tokens for this. The syntax for token differs between 2000 and 2005. If you
search Books Online for below, you will find more information:
token agent

--
Tibor Karaszi, SQL Server MVP
http://www.yqcomputer.com/
http://www.yqcomputer.com/
Blog: http://www.yqcomputer.com/
 
 
 

Getting Job name, Job ID , Step within the Job

Post by TUw » Wed, 21 Dec 2005 21:56:03

Ah, you mean using the COMMAND parameter of the sp_add_jobstep system
procedure?


ML

---
http://www.yqcomputer.com/
 
 
 

Getting Job name, Job ID , Step within the Job

Post by Aaron Bert » Wed, 21 Dec 2005 23:29:28

 
 
 

1. "germany jobs" "germany job sites" "germany job search" "jobs in germany" "german jobs" "germany jobs it" "germany jobs for foreigners" "germany jobsite" "germany jobs in english" on http://jobs-germany.blogspot.com/

2. "germany jobs" "germany job sites" "germany job search" "jobs in germany" "german jobs" "germany jobs it" "germany jobs for foreigners" "germany jobsite" "germany jobs in english" on http://jobs-germany.blogspot.com/

3. "germany jobs" "germany job sites" "germany job search" "jobs in germany" "german jobs" "germany jobs it" "germany jobs for foreigners" "germany jobsite" "germany jobs in english" on http://jobs-germany.blogspot.com/

4. "germany jobs" "germany job sites" "germany job search" "jobs in germany" "german jobs" "germany jobs it" "germany jobs for foreigners" "germany jobsite" "germany jobs in english" on http://jobs-germany.blogspot.com/

5. "germany jobs" "germany job sites" "germany job search" "jobs in germany" "german jobs" "germany jobs it" "germany jobs for foreigners" "germany jobsite" "germany jobs in english" on http://jobs-germany.blogspot.com/

6. "germany jobs" "germany job sites" "germany job search" "jobs in germany" "german jobs" "germany jobs it" "germany jobs for foreigners" "germany jobsite" "germany jobs in english" on http://jobs-germany.blogspot.com/

7. "germany jobs" "germany job sites" "germany job search" "jobs in germany" "german jobs" "germany jobs it" "germany jobs for foreigners" "germany jobsite" "germany jobs in english" on http://jobs-germany.blogspot.com/

8. "finland jobs" "google finland jobs" "helsinki finland jobs" "finland jobs english" "jobs in finland for foreigners" "jobs in finland for english" "jobs finland" http://jobs-in-finland.blogspot.com

9. "JOBS IN FINLAND" "JOBS FINLAND" "FINLAND JOBS" "ACCOUNTS JOBS IN FINLAND" "FINANCE JOBS IN FINLAND" "AGRI JPBS IN FINLAND" "MEDICAL JOBS IN FINLAND" ON JOBS http://jobs-in-finland.blogspot.com/

10. "JOBS IN ALABAMA" "ALABAMA JOBS" "ACCOUNTS JOBS IN ALABAMA" "FINANCE JOBS IN ALABAMA" ON http://jobsinalabama-usa.blogspot.com/ "USA JOBS" "JOBS IN USA" "JOBS IN USA STATES" "MEDICAL JOBS IN ALABAMA"

11. "JOBS IN FINLAND" "JOBS FINLAND" "FINLAND JOBS" "ACCOUNTS JOBS IN FINLAND" "FINANCE JOBS IN FINLAND" "AGRI JPBS IN FINLAND" "MEDICAL JOBS IN FINLAND" ON JOBS http://jobs-in-finland.blogspot.com/