January 27, 2009 at 8:56 am
Is it possible to set variables in a SQL agent job step and referring to that variable in other job steps? The only results I found in Google refer to SSIS packages.
Reason is I want to include a restore filepath for databases in a variable because this path is referenced in many job steps.
Of course there are other ways to do this such as creating a UDF or SP, but I would like to know if this is possible within the SQL Agent engine.
__________________
MS-SQL / SSIS / SSRS junkie
Visit my blog at dba60k.net
January 27, 2009 at 11:06 am
You can use variables in job steps.
But you can not refer to a variable that is in another step.
You have to declare them seperately. and the scope for the variables in a step is just within that step.
January 27, 2009 at 12:46 pm
Yes the scope of the variables are limited to the job step unfortunately.
Think I will go for the user defined function trick unless somebody has a better idea of course.
__________________
MS-SQL / SSIS / SSRS junkie
Visit my blog at dba60k.net
January 27, 2009 at 2:15 pm
Not sure what you really want to achieve.
Does your filepath dynamically change according to the job steps?
or is it just a static filepath that is repeatedly used?
If it is a static one, I think it is ok to declare the variable separatedly in different job steps;
If it is a dynamic one, u may want to combine the job steps into one step, if acceptable.
it is like doing several things in one job step.
Viewing 4 posts - 1 through 3 (of 3 total)
You must be logged in to reply to this topic. Login to reply