Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2005 Forums
 Transact-SQL (2005)
 Trap error in trigger

Author  Topic 

karlman
Starting Member

11 Posts

Posted - 2010-08-15 : 18:38:36
I have a trigger that logs changes in a particular field to an audit table. It works fine but I want to ensure if there is ever a problem with the trigger that the original transaction is still completed.

How do I trap an error and have it ignored? I tried using a TRY and CATCH block but even when the CATCH black fires the original transaction that fired the trigger still fails. Is there something I need to do to nullify the error?

Thank you
Karl

jen
Master Smack Fu Yak Hacker

4110 Posts

Posted - 2010-08-17 : 16:45:18
depending on the error,you can use @@error...otherwise sql server terminates the statement that triggered the error..

check this link for more info...
http://msdn.microsoft.com/en-us/library/aa937483%28SQL.80%29.aspx

--------------------
keeping it simple...
Go to Top of Page
   

- Advertisement -