0

I wrote a trigger for whenever an update occurs in the table. But the trigger is not executing after update. The db used is SQLServer.

create trigger mytrigger on t_emp after update
as
begin
   select * from t_emp
end

Thanks

Alex Aza
  • 73,821
  • 25
  • 151
  • 132
Thomas Mathew
  • 1,131
  • 5
  • 15
  • 30

1 Answers1

2

Triggers are used for further processing after UPDATEs or INSERTs etc, typically for history or audit tables, or for complex data integrity logic. Not for data retrieval. Triggers can break a lot of client code (see this on SO)

  • To get the output of what you've just updated, use the OUTPUT clause.
  • To get all rows from the table, use a second SELECT statement
Community
  • 1
  • 1
gbn
  • 408,740
  • 77
  • 567
  • 659