2

is it possible to declare one Sql Trigger Insert, Update, Delete for all tables in the database instead of creating a separate trigger for each table? I just want a simple history of what actions have been taken e.g. TABLE A deletes a row ,TABLE B updates a row ,TABLE C Add new row .. and the trigger will insert a new row to another table with that information I want.

Radu Gheorghiu
  • 20,049
  • 16
  • 72
  • 107
Stelios
  • 330
  • 5
  • 21
  • The best you can do is to define a procedure and create a trigger for each table then call it on every trigger. But, in order to do this you will have to figure out a way to pass the parameters to the procedure unless every table has the same parameter and it is this one you like to change. – Jorge Campos Dec 02 '13 at 12:09

1 Answers1

1

No, a trigger can only be defined on a specified table.

You should read up on the auditing features of SQL Server (http://technet.microsoft.com/en-us/library/cc280386.aspx). They are more performant and more flexible in what you want to achieve. Unfortunately they are not available in the Express Edition.

Twinkles
  • 1,984
  • 1
  • 17
  • 31
  • hi, i have read about that feature but when i follow the instructions they are missing from the management studio, i guess that this may not supported in free edition of SQL EXPRESS 2012 – Stelios Dec 02 '13 at 11:54
  • management studio express is available as part of the 'tools' - you can get it for express also – Dawesi Feb 19 '14 at 00:47