如何并行运行 sql server 存储过程?

2021-12-30 00:00:00 sql parallel-processing tsql sql-server dts

我想做类似的事情:

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?

相关文章