hey ,
im new to SQL. i wanted to save a particular record before deleting it usin
g a delete trigger can anyone help me on this .. thnxIO you want to store the whole row and therefore the data you could
consider leaving the data in the table and marking the row as "deleted"
by flagging the row with a bit column as deleted. If you don=B4t want to
maintain the whole row you could do something like this:
CREATE Trigger DELTrg_SomeTable ON SomeTable
FOR DELETE
AS
BEGIN
INSERT INTO SOmeTable
SELECT * from Deleted
/*
Rather than using the asterix to Select the column and data I would
namer the columns you want to select and insert therefore lgiving you
the opputunity to fill in additional fields which are extended int he
archive (something like an audit data, who deleted what row from what
host, etc.)
*/
END
HTH, Jens Suessmeyer.
No comments:
Post a Comment