在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

 

posted @ 2010-03-16 22:32  昝昝  阅读(226)  评论(0编辑  收藏  举报