Question : trigger syntax MSSQL

Hi Experts

i am trying to test a trigger that could have a problem so i try to run it in analyzer
but the i get error that deleted table is invalid object.
this is the code part:

begin transaction
delete from ESL_SETTING_DATA where ID_1=4211
SELECT esl_setting_data_id FROM DELETED
commit transaction

i will appreciate your help
10x

Answer : trigger syntax MSSQL

This is beacause in the trigger environment - after deleted, there is a "new table" created on the fly called deleted with the original values in it.

To Mimic this - create a table (same structure as original delete row) - call it deleted and populate it with a record - which you will be pretending to delete.

(be sure not to copy that into the trigger as the object exists there already) - you will need to use [deleted] as deleted is a reserved word :)

Random Solutions  
 
programming4us programming4us