Friday, July 18, 2008

How use trigger in sql

Example of Delete trigger

CREATE trigger [TRIGGER_Deletesubcategory] ON dbo.category

FOR delete

AS

declare @nmid int

select @nmid=sno from deleted

delete from subcategory where cat_id= @nmid

There will be two table one is category and second one is subcategory and the primery key of category table will be sno and the this will foreign key(cat_id) for subcategory table.









No comments: