在sql server中有没有办法并行插入Temp表 [英] Is there a way in sql server to Insert into Temp Table parallely

查看:127
本文介绍了在sql server中有没有办法并行插入Temp表的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

I have a Dynamic SQl Query as below

Create #TempTable(ColumnA int, ColumnB int, ColumnC Int)

Insert into #TempTable(select A,B,C from Table1 where  some condition formed dynamically)
Insert into #TempTable(select A,B,C from Table1 where  some condition formed dynamically)
Insert into #TempTable(select A,B,C from Table1 where  some condition formed dynamically)
Insert into #TempTable(select A,B,C from Table1 where  some condition formed dynamically)
Insert into #TempTable(select A,B,C from Table1 where  some condition formed dynamically)

select * from #TempTable
drop table #TempTable





注意:#TempTablecan中的插入语句数量从10到100不等因此需要大量的时间执行



我想知道的是,在SQL Server 2008 R2中是否有一种方法可以使用它来并行执行Insert语句并缩短执行时间? ?



Note : The Number of insert statements into the #TempTablecan vary from 10 to 100 hence it takes a lot of time to execute

What i wanted to know is , Is There a way in SQL server 2008 R2 using which i can execute the Insert statements parallely and Reduce the Execution Time??

推荐答案

如果你的条件在每一行都没有变化那么试试.. :)



if your condition is not varying at every row then try that.. :)

SELECT * INTO #TempTable FROM SourceTable WHERE.....--condition 


这篇关于在sql server中有没有办法并行插入Temp表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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