Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 182
  • Last Modified:

Get the trigger name that is failing

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
Mackey_man
Asked:
Mackey_man
2 Solutions
 
zvytasCommented:
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
 
eridanixCommented:
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
 
Mackey_manAuthor Commented:
Thanks for taking the time to help me.
0

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now