Solved

Get the trigger name that is failing

Posted on 2011-09-22
3
169 Views
Last Modified: 2012-05-12
Hi there

A customer of mine has a table with 11 triggers that fires for inserts, updates and deletes. One of these triggers fails and an error message is displayed, unfortunately it doesn't point me to the trigger that is causing the error. Is there any way I can see which trigger it is that causes the error message ? Can I run  a query and get hold of this information  ? I know it's not good practise to have so many triggers on one table but that's not my idea.
0
Comment
Question by:Mackey_man
3 Comments
 
LVL 5

Assisted Solution

by:zvytas
zvytas earned 125 total points
ID: 36580459
Error message should contain some details about the trigger that is failing. Providing error message would be helpful.
Another way to solve this is disabling triggers one by one and trying to insert/update/delete data. It can take a while, but would allow to solve the problem. Disabling a trigger can be done with the following SQL statement:

DISABLE TRIGGER <trigger name> ON <table name>

Enabling trigger can be done as follows:

ENABLE TRIGGER <trigger name> ON <table name>
0
 
LVL 5

Accepted Solution

by:
eridanix earned 125 total points
ID: 36890203
Hi,

if you can edit triggers, you can add error condition, which can you tell in which trigger or triggers throws error.
To the end of each trigger add for example:

IF @@ERROR <> 0
BEGIN
        INSERT INTO dbo.SomeLogTable (error) VALUES ('name_of_trigger')
END

More information here:
http://msdn.microsoft.com/en-us/library/aa933181%28v=sql.80%29.aspx
http://www.sqlteam.com/article/an-introduction-to-triggers-part-i
0
 

Author Closing Comment

by:Mackey_man
ID: 36891484
Thanks for taking the time to help me.
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Confronted with some SQL you don't know can be a daunting task. It can be even more daunting if that SQL carries some of the old secret codes used in the Ye Olde query syntax, such as: (+)     as used in Oracle;     *=     =*    as used in Sybase …
This article describes how to use the timestamp of existing data in a database to allow Tableau to calculate the prior work day instead of relying on case statements or if statements to calculate the days of the week.
This Micro Tutorial hows how you can integrate  Mac OSX to a Windows Active Directory Domain. Apple has made it easy to allow users to bind their macs to a windows domain with relative ease. The following video show how to bind OSX Mavericks to …
Along with being a a promotional video for my three-day Annielytics Dashboard Seminor, this Micro Tutorial is an intro to Google Analytics API data.

863 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

24 Experts available now in Live!

Get 1:1 Help Now