如何并行运行 sql server 存储过程? [英] How can I run sql server stored procedures in parallel?

查看:72
本文介绍了如何并行运行 sql server 存储过程?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想做类似的事情:

exec sproc1 and sproc2 at the same time
when they are both finished exec sproc3

我可以在 dts 中做到这一点.有没有办法在事务 sql 中做到这一点?或者有没有办法用批处理脚本(例如 vbs 或 powershell)来做到这一点?

I can do this in dts. Is there a way to do it in transact sql? Or is there a way to do it with a batch script (eg vbs or powershell)?

推荐答案

sp _ start _ job

sp _ start _ job

我目前正在做类似的事情,我发现避免使用 SSIS 或某些外部 shell 的唯一方法是手动将我的加载例程拆分为线程",然后启动单个主 sqlagent 作业它依次执行与我有线程一样多的 sp _ start _ 作业.从那时起,它们都可以自主运行.

I'm doing a similar thing at the moment, and the only way I've found to avoid using SSIS or some external shell is to split my load routine into 'threads' manually, and then fire a single master sqlagent job which in turn executes as many sp _ start _ job's as I have threads. From that point, they all run autonomously.

这不完全是我们要找的东西,但结果是一样的.如果您测试子作业的作业状态,您也可以实现 sproc 3 的有条件启动.

It's not exactly what we're looking for, but the result is the same. If you test the job status for the sub jobs, you can implement your conditional start of sproc 3 as well.

如果我们不能同时使用 8 个内核,那还有什么意义?

What's the point in 8 cores if we can't use them all at once?

这篇关于如何并行运行 sql server 存储过程?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆