processing two queries at the same time

I have a stored procedure that loads data from two sources into temporary tables then merges the results.

The imports run sequentially, ie INSERT #1 runs to populate temp table 1, then INSERT #2 to populate table 2....

I want to speed up the operation by running both inserts at the same time. Is that possible in SQL server?
LVL 1
craigdevAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

mastooCommented:
Interesting question.  I'll be interested in a better answer than mine.

You could combine the operations into a single sql statement and hope that sql server will optimize it with parallelization.

Otherwise the only thing comes to mind would be to host the load operations outside of sql, either in another application or sql agent.  For instance you could make each load a sql agent job and then have a proc that starts both jobs and polls them waiting for completion before using the results (though this seems pretty ugly).

Practically speaking, I might guess the best answer is "no"
0
tpi007Commented:
The quickest way would be outside of SQLbut not sure if it is appropriate to do in SSIS; internally mastoo is probably correct.
You can perform these tasks in parallel by creating 2 dataflow tasks that run concurrently in an SSIS package and run package via sql agent task.
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft SQL Server 2005

From novice to tech pro — start learning today.