hi
this is ramamoorthy i need a help how to implement trigger in sqlserver
I have problem in trigger
1 Answer
Know the answer? Post it. Somebody with the same question will find it here.
Know the answer? Post it. Somebody with the same question will find it here.
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questions
DevSocialUpcoming · 3rd editionAI Agents ConferenceDec 1–3, 2026Live onlineFree to attend4days leftRegister
Posted Aug 2, 2007, 1:56 AM EDT
It's very simple to create trigger. Trigger automatically fires when u perform any operations(insert,update and delete) on the table. Here i am writing one sample trigger for delete.
CREATE TRIGGER MySample ON [TableName] FOR DELETE AS IF (SELECT state FROM deleted) = ‘AnyValue’ BEGIN PRINT ‘Can not remove customers from AnyValur' PRINT ‘Transaction has been canceled’ ROLLBACK END