I need to create a SQL JOB.
Step1: Insert a Row into TaskToProcess Table and return ProcessID(PK and Identity)
Step2: Retrive the ProcessID which is generated in step1 and pass the value to SSIS package and execute the SSIS Package.
Is this Possible in SQL server JOB??
Please help me on this
Thanks in advance.
Similar to Ed Harper's answer, but some details found in "Variables in Job Steps" MSDN forum thread
The Process-Keyed Tables are described in article "How to Share Data between Stored Procedure"
Another suggestion in Send parameters to SQL server agent jobs/job steps MSDN forum thread to create a table to hold the parameters, such as:
There is no built-in method of passing variable values between job steps. However, there are a couple of workarounds.
One option would be to store the value in table at the end of step 1 and query it back from the database in step 2.
It sounds like you are generating
ProcessID
by inserting into a table and returning theSCOPE_IDENTITY()
of the inserted row. If job step 1 is the only process inserting into this table, you can retrieve the last inserted value from job 2 using theIDENT_CURRENT('<tablename>')
function.EDIT
If multiple process could insert into your process control table, the best solution is probably to refactor steps 1 and 2 into a single step - possibly with a controlling SSIS master package (or other equivalent technology) which can pass the variables between steps.