SQLServerでOUTPUT文によるデータの削除とデータのバックアップを実現
1404 ワード
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