all groups > sql server programming > february 2007 >
You're in the

sql server programming

group:

SP checking if running under a job? and if so, getting jobname and jobid?


SP checking if running under a job? and if so, getting jobname and jobid? jobs
2/20/2007 10:34:59 PM
sql server programming:
Is it possible for an SP to check to see if it's running as job, and
if so, get it's own jobname and jobid?

Also curious, does any know, is it possible to use ssis variables to
set the connection, operation and file type settings in an ssis ftp
task or must those items be preset?
Re: SP checking if running under a job? and if so, getting jobname and jobid? lucky
2/20/2007 10:45:39 PM
[quoted text, click to view]


You can query on sysjobsteps on MSDB and look for SP name in command
field

Select [Name] AS JobName from SysJobs SJ Inner Join SysjobSteps SJS ON
SJ.Job_ID = SJS.Job_ID WHERE SJS.Command Like '%SP Name Goes Here%'

Thanks
Mahesh
Re: SP checking if running under a job? and if so, getting jobname and jobid? jobs
2/20/2007 10:52:46 PM
[quoted text, click to view]

I was hoping there would be something more concrete. I'm creating the
jobs on the fly and inserting the sp on the fly into it as well. There
will be the chance that two jobs could be running the same sp at the
same time.

No way to get current session information and connect the dots that
way?

thank you!
Re: SP checking if running under a job? and if so, getting jobname and jobid? lucky
2/20/2007 11:03:42 PM
[quoted text, click to view]


If you are creating the job on the fly, you should have the job name
within the scope already. Probably I am not understanding your
requirement clearly.
Re: SP checking if running under a job? and if so, getting jobname and jobid? jobs
2/21/2007 5:08:31 AM

[quoted text, click to view]

Very true. I'm trying to pass parameters to an SSIS FTP task and
launch it asynchronously as a job. I thought launching the package
from sp would make sense - it actually does not. I guess I need to
understand how parameters are passed to SSIS packages in a job.
Re: SP checking if running under a job? and if so, getting jobname and jobid? jobs
2/21/2007 5:22:27 AM
[quoted text, click to view]

The issue is that that there might be two FTP jobs launched at the
same time and so the SSIS package needs some identifier so it knows
what job (or unique id) to find it's parameters under.

Or perhaps I need to change the design so that the FTP Task processes
*any* pending FTPs in serial. Not Ideal, but it would solve the "which
one am I" questions.

Thank you
AddThis Social Bookmark Button