Solved

Get the trigger name that is failing

Posted on 2011-09-22
3
167 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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

'Between' is such a common word we rarely think about it but in SQL it has a very specific definition we should be aware of. While most database vendors will have their own unique phrases to describe it (see references at end) the concept in common …
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 …
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, Just open a new email message.  In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…
Illustrator's Shape Builder tool will let you combine shapes visually and interactively. This video shows the Mac version, but the tool works the same way in Windows. To follow along with this video, you can draw your own shapes or download the file…

744 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

12 Experts available now in Live!

Get 1:1 Help Now