本文介绍了删除 SQL Server 2005 记录而不记录的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如何从 SQL Server 2005 表中删除记录而不将它们记录到事务日志中.
How to delete records from SQL Server 2005 tables without logging them into transaction logs.
我不想记录,因为一旦删除,这些记录将不再需要.
I do not wish to log because once deleted, those records will never be needed again.
目前各种删除花费的时间太长.还有其他选项可以提高删除语句的性能吗?我不能使用 truncate,因为需要一个 where 子句.
Currently the various deletes take too much of time. Are there any other options to improve performance of delete statements? I can not use truncate since there is a where clause needed.
推荐答案
很简单:
DECLARE @BatchSize INT
SET @BatchSize = 100000
WHILE @BatchSize <> 0
BEGIN
DELETE TOP (@BatchSize)
FROM [dbo].[UnknownTable]
SET @BatchSize = @@rowcount
END
这篇关于删除 SQL Server 2005 记录而不记录的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!