sqlserver 大數據量的insert、delete操做優化

http://blog.csdn.net/lanyuzhen/article/details/7547476.net

--大批量導出orders表:insertblog

DBCC DROPCLEANBUFFERS  
DBCC FREEPROCCACHE 
go
SET NOCOUNT ON 
BEGIN TRANSACTION  
INSERT INTO test.dbo.orders with(tablock) SELECT * FROM 
bak.dbo.Orders
WHERE ordertime BETWEEN '2010-05-01' AND '2010-05-10'
COMMIT
goit


--大批量導出orders表:deletetest

DBCC DROPCLEANBUFFERS  
DBCC FREEPROCCACHE 
go
SET NOCOUNT ON 
BEGIN TRANSACTION  
while 1=1  
begin 
 delete top(1000) from test.dbo.orders with(tablock) 
WHERE ordertime BETWEEN '2010-05-01' AND '2010-05-10'
if @@rowcount<1000 
 break  
end 
COMMIT
goim

相關文章
相關標籤/搜索