如何使用存储过程插入和删除相同的数据 [英] How to Insert and delete the same data using Stored Procedure
本文介绍了如何使用存储过程插入和删除相同的数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个名为tblManpowerCollection的表。我必须删除'01 -10-2013'到'05 -05-2013'的数据,日期将从tblManpowerCollection的AttDate
列中获取,并将删除的数据插入另一个表中备份。我怎么能使用存储过程来做到这一点。请帮帮我。
I have a table named tblManpowerCollection. I have to delete data from '01-10-2013' to '05-05-2013' and the date will get from "AttDate"
column of tblManpowerCollection and insert the deleted data into another table as backup. How can I do that using stored procedure. Please help me.
推荐答案
这里有一个样本
Here a sample
CREATE PROCEDURE uspGetAddress
AS
INSERT INTO Table1_Backup(Column1, Column2) SELET Column1, Column2 FROM tblManpowerCollection WHERE DateColumn BETWEEN '01-10-2013' to '05-05-2013' --Insert records to backup table before delete
DELETE FROM Table1 WHERE DateColumn BETWEEN '01-10-2013' to '05-05-2013' --Delete records after backup
但请注意日期格式 [ ^ ]。我会使用 UPDATE而不是DELETE [ ^ ]
But careful with Date formats[^]. And I'd use UPDATE instead of DELETE[^]
这篇关于如何使用存储过程插入和删除相同的数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文