日结处理 SQL实现
概念:
当前表,历史表,营业日
1、将当前单据表中的销售记录(已完成)转移到历史表中
2、删除当前表的销售记录(已完成)
3、更改营业日期
CREATE PROCEDURE [sp_ExecuteBizdayOver]
(
@BusinessDistrictCode nvarchar(5),
@Bizday datetime
)
as
insert into M_Order_H
select * from M_Order where substring(OrderID,2,5) = @BusinessDistrictCode
delete from M_Order where substring(OrderID,2,5) = @BusinessDistrictCode
update M_BizDay set BizDay = @Bizday
GO