Is it allowed to pass Job variables to database operation?

TJ (32 posts)
May 6, 2020 01:24 PM
Accepted Answer

I've been using database operation task to return data to job variables? Is there a way to pass job variables to script that executed by database operation task, like job name?

Thanks

Bill Staff (599 posts)
May 7, 2020 11:40 AM
Accepted Answer
Yes. You can insert a variable in the SQL that the task executes using the "%variablename%" syntax. See here for a list of predefined variables that you can use, in addition to any variables that you have defined yourself.
TJ (32 posts)
May 8, 2020 12:47 PM
Accepted Answer
Thank you! Can I save the database operation step to be shared in other tasks? I have same statement to be run in every task, it would be very useful if I can use it as template. 
Bill Staff (599 posts)
May 8, 2020 01:31 PM
Accepted Answer
You can't save the step to be used in other jobs. However, you can take the entire SQL statement and put it in a Job Variable (for example "SqlToExecute") and then for each task just put "%SqlToExecute%" as the SQL statement to run.

Replies are disabled for this topic.