Click here to Skip to main content
15,906,558 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
hi i want to create a trigger for rollback transaction, for exampel user can not delete a record from TblParaCode.
please help me .
this is my code
SQL
Create Trigger [dbo].[Test01]
On  TblParaCode
AFTER UPDATE,delete
AS
begin
if ((SELECT paracode From TblParaCode where typecode=29) =2)
begin
  RAISERROR('Cannot delete this record.',16,1)

 rollback transaction
end
end



thanks.
Posted

1 solution

Refer - COMMIT and ROLLBACK TRANSACTION in Triggers[^].

You need to use INSTEAD OF the DML operation.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900