2 个解决方案
#1
create proc test
as
set nocount on
insert into A_his(Id,name,scores)
select Id,name,scores
from A
where .................
delete from A
where .................
go
然后定时运行job,规定每天0点定时运行
as
set nocount on
insert into A_his(Id,name,scores)
select Id,name,scores
from A
where .................
delete from A
where .................
go
然后定时运行job,规定每天0点定时运行
#2
如果A和A_His结构一致,可用
delete A output deleted.* into A_His from A where ...
delete A output deleted.* into A_His from A where ...
#1
create proc test
as
set nocount on
insert into A_his(Id,name,scores)
select Id,name,scores
from A
where .................
delete from A
where .................
go
然后定时运行job,规定每天0点定时运行
as
set nocount on
insert into A_his(Id,name,scores)
select Id,name,scores
from A
where .................
delete from A
where .................
go
然后定时运行job,规定每天0点定时运行
#2
如果A和A_His结构一致,可用
delete A output deleted.* into A_His from A where ...
delete A output deleted.* into A_His from A where ...