Error handling with Error 2601

Posted on 2010-01-01
Last Modified: 2012-05-08
I make with my sp insert statements in a table(1) with two indexes.
The indexes are both INT and are managed with own tables (2) and (3).
Now it can happen that a administrator makes also insert statements manual and forget to update the Index manage tables (2) or/and (3).
If my sp now will write down the next dataset I get the Error 2601.
This Error occurs by both indexes.
How can I find out now wich index I have to correct it? Or how can I get the column name of the error index? I think it is not reliable to extract the Error_message.
Question by:Opusretis
    LVL 41

    Accepted Solution

    Hmm, stupid administrator could do even worst things...

    You should think if you have to add some conditional data testing before each insert (to indicate manual data integrity corruption) or if you rather change the administrator or if you write a set of SPs for administrative use which could update tabels 2 and 3 automatically.

    So, if you have SP for insert statements then you should check if the inserted values are valid before the operation itself. Some automatic increment of values in table 2 and 3 would also be possible.

    And if the error just occured and you don't know which table contains wrong value then you have to query both table 2 and 3 and compare values against data in table 1. Broken uniqueness is easy to trace.

    Author Closing Comment

    The proposal is good because it avoid an Error but it is not an Errorhandling.
    Whatever the problem is solved!

    Thank you

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Top 6 Sources for Identifying Threat Actor TTPs

    Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

    SQL Server engine let you use a Windows account or a SQL Server account to connect to a SQL Server instance. This can be configured immediatly during the SQL Server installation or after in the Server Authentication section in the Server properties …
    How to leverage one TLS certificate to encrypt Microsoft SQL traffic and Remote Desktop Services, versus creating multiple tickets for the same server.
    To add imagery to an HTML email signature, you have two options available to you. You can either add a logo/image by embedding it directly into the signature or hosting it externally and linking to it. The vast majority of email clients display l…
    Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.

    760 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

    8 Experts available now in Live!

    Get 1:1 Help Now