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
  • 76,499
  • 26
  • 155
  • 134
Thomas Mathew
  • 1,151
  • 6
  • 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
  • 422,506
  • 82
  • 585
  • 676