Save Data to Archive Table When Delete From Table With T-SQL OUTPUT INTO Clause


CREATE PROCEDURE [dbo].[sp_signup_DeletedRecord]
(
@UserName NVARCHAR(50)
)
AS

Begin
DELETE FROM signup
--Change col1, col2,col3… to column names from your signuptable
OUTPUT deleted.col1,
deleted.col2,
deleted.col3
INTO DeletedRecord
WHERE UserName = @UserName
End


Reference:
http://msdn.microsoft.com/en-us/library/ms177564(v=sql.90).aspx

Advertisements


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s