嘿,我現在只是變得很懶。但是,我知道你們都可以幫助我,這是件好事。如何更改此過程以便在SQL Server 2005中逐日刪除記錄
我有一個表清理和刪除過程,每晚運行。它已經足夠基本,並且可以刪除數據庫中超過3天的任何記錄。
由於當我們每次刪除超過1天的記錄時,我們得到的事務日誌已滿錯誤。更改事務日誌設置會很麻煩。
SOO,有人可以告訴我如何更新proc,以便它從3天前刪除所有內容,可以說通過7天。含義返回3天,然後在過去7天內每次刪除一個表中的數據。
我們是一個全天候監控的能源商店,我可以肯定它是否會在7天內有人會注意到。
ALTER PROCEDURE [dbo].[PruneData]
(
@cutoffDate DateTime
)
AS
BEGIN
declare @threeDayCutoffDate DATETIME
set @threeDayCutoffDate = dateadd(hh, 5, DATEADD(dd, -3,dbo.DateOnly(getutcdate())))
delete from LMP_DayAhead where interval < @threeDayCutoffDate
delete from LMP_RealTime where interval < @threeDayCutoffDate
delete from LMP_RealTimeIntegrated where interval < @threeDayCutoffDate
delete from ZonalMCP where interval < @threeDayCutoffDate
delete from SyncJob where synctime < @threeDayCutoffDate
RETURN
END
嘿,你在一家電力公司工作!涼。 – 2011-02-08 19:38:21
調查分區...這是要走的路。 – 2011-02-08 20:00:20