Monday, July 29, 2013

how to see log how many times trigger on my table executed

What version of SQL Server are you using?



There is an interesting DMV in SS 2008, that could help if the trigger is still in the cache.



sys.dm_exec_trigger_stats

http://msdn.microsoft.com/en-us/library/cc280646.aspx



In case you decide to go with the suggestion made by Chirag and Hugo, to use a table to log every execution of the trigger, keep in mind that we do not have autonomous transactions in SQL Server yet. If the operation is rolled back, then the log for that execution will be lost. Here is a trick to handle this in SS 2008.



How to create an autonomous transaction in SQL Server 2008

http://blogs.msdn.com/sqlprogrammability/archive/2008/08/22/how-to-create-an-autonomous-transaction-in-sql-server-2008.aspx





AMB

No comments:

Post a Comment