首页 > 代码库 > sqlserver 大数据量的insert、delete操作优化
sqlserver 大数据量的insert、delete操作优化
http://blog.csdn.net/lanyuzhen/article/details/7547476
--大批量导出orders表:insert
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
go
--大批量导出orders表:delete
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
go
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。