how to use trgger in asp.net

hi Nadeem,

Triggers r those that get executed whenever an event occurs. So u can write them normally in sql and in asp.net, when u try to insert or update, the trigger get automatically fired at the backend. You can create a trigger in sql enterprise manager. The below one is an example of a trigger on insert.

CREATE trigger trig_additem //trigger name
on item //table name
for insert //the specific event, u want the trigger to b fired
as
declare @newitem varchar(20)
select @newitem= (select item_name from inserted)
print 'New Item @newitem "' + @newitem +'" added'


Regards
 
Back
Top