views:

422

answers:

1
   id    country_name   region     area         population

    1   LASvega      Americas    2314       2134562  
    2   California   AMERICAS    10101      2134562 
    3   Algeria      Middle East   24000000   32900000 
    4   Andorra      Europe        468       64000

fire a delete query , just before that this trigger is fired and saved that said record into another table.. if i want to delete record no 3 then saved it into another table.

+3  A: 

You can use the special Deleted table that is available within an UPDATE or DELETE trigger.

CREATE TRIGGER trg
ON tbl
FOR DELETE

INSERT INTO OtherTable
   SELECT * FROM Deleted
dnolan
i want to delete specific record which is given by user. and before that i want to fired trigger . and save that deleted row into another table give any name.
Sikender
@Sikender: SQL Server does not offer a before delete trigger. However during the firing of the after delete trigger, the rows that were deleted are available in the pseudo table DELETED. dnolan has the right idea for how to save those rows.
Shannon Severance
@Sikendar: the only other alternative to capturing before the delete is to use a stored procedure that wraps the delete command plus whatever code you wish to execute before it
dnolan