2017-06-28 26 views
-2

我有大表,我需要在表的每個記錄上做一些處理。處理1行1秒。表有超過500k的記錄。我不能用一個查詢。我計劃通過5部分並行運行我的查詢。每個在100k記錄上運行。如何通過每個查詢讀取不同的100k記錄,以便1行只處理一次。如何通過在sql server中並行運行多個腳本來獲得不同的行?

+0

處理與更新?你的意思是你要同時運行它?立即啓動5個更新語句?你的問題不清楚 – scsimon

回答

0

我會考慮使用ntile。這裏是一個例子:

select column1, ntile(5) over (order by Column1) 
from 
(
select 1 as Column1 
union all select 2 
union all select 3 
union all select 4 
union all select 5 
union all select 6 
union all select 7 
union all select 8 
union all select 9 
union all select 10 
) as b