在SQLServer 中利用OUTPUT 语句实现删除数据的同时备份数据
CREATE PROCEDURE dbo.Up_DeleteAndBackupTask
(
@TaskID INT,
@TaskStatus CHAR(1)
)
AS
BEGIN
SET NOCOUNT ON
DELETE dbo.tblTask
OUTPUT
DELETED.TaskID
,'Delete'
,DELETED.TaskStatus
,GETDATE()
INTO dbo.tblTask_Backup
WHERE TaskID = @TaskID
AND TaskStatus = @TaskStatus
END
GO