Click here to Skip to main content
15,896,915 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
hi I want to create a TRIGGER on SQL Server 2012
I have 2 table.
when user try to delete a record from table one,if this record was in table tow,
rollback transaction and user can not delete.
thank
Posted
Comments
Thomas ktg 16-Nov-13 4:01am    
Have you tried something to show here?
José Amílcar Casimiro 16-Nov-13 8:39am    
Improve your question with table schema.

1 solution

You will want use the INSTEAD OF keywords.

CREATE TRIGGER [name] ON [table] INSTEAD OF DELETE AS


In the trigger you can check with a select statement and if it is deleteable run

DELETE FROM [table] FROM [Table] a INNER JOIN deleted d ON a.[key] = d.[key]


Good Luck
 
Share this answer
 
v2

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