tags:

views:

116

answers:

2

I need to start a SSIS package via a stored procedure. I chose to use 'exec dtexec' instead of starting a job to launch the package, so I can have the ability to set variable in the package. My problem is that I need the package to run asynchronously so that the stored procedure will return instead of it hanging or timing out.

What is the best practice for achieving this?

A: 

Use the stored proc to start a SQL Server Agent job that invokes the SSIS package...

You can't invoke directly from a stored proc (which is not a good idea anyway) and then have the stored proc terminate. You have to decouple the stored proc execution from the SSIS execution

Setting variables is easy though in SQL Server agent (GUI) and on command line (use /Set)

gbn
I would, but how do you pass variables form the stored proc to the ssis package to then pass into the SSIS package? I can't think of a way, that is why I was trying to do it by using dtexec, where I can pass in command line args.
aceinthehole
@aceinthehole: why must it be a stored proc? This limits your options because it can't be asynch. You could use a table to stored the parameters...
gbn
I am calling it from BizTalk, SSIS is doing some heavy lifting that I want BizTalk to fire and wait for a response back from SSIS. BizTalk will be on a separate server than SSIS. So I was using a stored proc, doesn't necessarily have to be.
aceinthehole
+1  A: 

If you want Async operation with variables, I would construct a table to hold the variables you wanted to pass in, and an Agent job launched SSIS with them. Then you could use sp_start_job to launch that job asynchronously. The package could read the variables it needed from the table, or the job could read them to construct an appropriate launch command. The package could even update the table to indicate results back to BizTalk.

Todd McDermid
In fact, I used a file to pass in this info and another file to pass the info back. Not an optimal solution, however it works well with BizTalk, which is what I am using it with.
aceinthehole