--1.移除历史记录(一周前的) [每天23:30执行一次]
declare @weekday int
set @weekday=((select datepart(weekday,getdate()))%7+1)
alter table UpdateInfo_Hist10
switch partition @weekday
to UpdateInfo_Histtemp


--2.清除历史记录 [每天23:30执行一次]
truncate table UpdateInfo_Histtemp;


--3.将处理完的数据转移到临时表(每小时一次或每天一次)
alter table UpdateInfo
switch partition 2
to UpdateInfo_Temp


--4.从临时表插入到历史表中
insert into UpdateInfo_Hist10(ID,Ctime,TableID,FromGuid,ToGuid,RowNum,Flag,WeekDay)
select ID,Ctime,TableID,FromGuid,ToGuid,RowNum,Flag,datepart(weekday,ctime) as WeekDay
from UpdateInfo_Temp

--5.清除临时表数据
truncate table UpdateInfo_Temp

相关文章:

  • 2021-11-06
  • 2022-12-23
  • 2022-12-23
  • 2021-09-30
  • 2021-09-21
  • 2022-02-19
  • 2021-12-03
猜你喜欢
  • 2022-12-23
  • 2021-05-18
  • 2021-05-18
  • 2022-01-17
  • 2021-05-09
  • 2021-08-10
  • 2021-10-24
相关资源
相似解决方案