(在操作前备份数据库,停止应用)
1、生产库先执行01、02、03脚本
01 取消SPSDeductionLog外键关联.sql(如外键关联不存在就不运行这脚本)
02 建立分表.sql(如分表存在就不运行这脚本)
03 IMSCQLOGTABLE_SAVE_SPS
2、生产库运行命名 EXEC dbo.IMSCQLOGTABLE_SAVE_SPS @days = 10, @action = 0,@while=1000
3、保存数据库备份表记录条数
4、进入历史库执行脚本
04 BAK_CQIMSTABLE_SAVE_SPS.sql
5、历史库执行
EXEC dbo.BAK_CQIMSTABLE_SAVE_SPS @days = 10, @action = 0
6、确认记录条数正常
7、生产库执行
USE [imscq]
TRUNCATE TABLE SPSDeductionLog_2bak
TRUNCATE TABLE eai_pull_SPSPickList_2bak
TRUNCATE TABLE STKTrans_2bak
TRUNCATE TABLE INVSKU_2bak
8、重建索引
附快速查询表记录数:
select t.name as TableName,i.rows as [RowCount]
from sys.tables as t, sysindexes as i
where t.object_id = i.id and i.indid <=1
--AND t.name='eai_pull_SPSPickList'
AND t.name IN ('SPSDeductionLog_2bak','eai_pull_SPSPickList_2bak','STKTrans_2bak','INVSKU_2bak')
-- AND t.name IN ('SPSDeductionLog','eai_pull_SPSPickList','STKTrans','INVSKU')
ORDER BY t.name
附快速查询表记录数:
select t.name as TableName,i.rows as [RowCount]
from sys.tables as t, sysindexes as i
where t.object_id = i.id and i.indid <=1
AND t.name IN ('SPSDeductionLog','eai_pull_SPSPickList','STKTrans','INVSKU','eai_pull_note','eai_pull_items',
'eai_pull_pick','ASNHeader','ASNDetail','SOHeader','SODetail','SOPickup')
ORDER BY t.name