question

noblez_jc avatar image
noblez_jc asked

Can the line of codes inside a Stored Procedure run Multi-threaded ?

I have a parent procedure, which runs the Several(40) child procedures inside. These child procs can run independently, parallel and asynchronous. Is there any mechanism in SQL server which helps me to run this asynchronous. Any help appreciated Thanks, Noble.
tsql
10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

1 Answer

·
Kev Riley avatar image
Kev Riley answered
This can be achieved by having SQL jobs started instead of calling SPs - as there's no way out-of-the-box that you can async call a SP. The downside is that often the user calling the proc doesn't have permissions to run sp_start_job. Another way would be to write a value to a table, and have a scheduled job that checks every x minutes for a value and then run the subsequent SPs. Neither seem clean and succinct approaches. Other approaches can involve Service Broker or MSMQ to place a 'request' on a queue.
10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.