Return Error 2147217873

  • I have a series of stored procedures that validate data and then do an insert in to multiple tables in the database.

    There is a master procedure that is called. The master proc calls a validation proc then depending on success and failure will call other procs.

    So I'm calling this master proc from VB6 code and SQL is returnning an error: 2147217873 from a proc that is 3 or 4 levels deep. The error description that is returned is nothing more than a SQL print statement (i.e. in the proc I execute the code: Print 'Line 123 Proc Name...') That is was is being returned as an error. This does not happen every time the proc is executed just randomly. I am using a transaction in the master proc so if there is an error it will rollback the entire transaction... even when I get the error the data is inserted and saved to the correct tables...

    Does any one know why I would be getting this error? What does the error mean? And why is it returning my print statement as the error description?

    Thanks in advance for any help...

  • I'm pretty sure that error 2147217873 is a foreign key violation;

    ie

    Error Code : -2147217873

    INSERT statement conflicted with COLUMN FOREIGN KEY constraint 'FK_ForeignKeyName'. The conflict occurred in database 'DatabaseName', table 'TableName', column 'Exposureid'.

    that would explain how it's kind of hard to track down, since sample data may have the value for the key;

    maybe the code is trying to insert a zero in a foreign key field because of an ISNULL or something?

    Lowell


    --help us help you! If you post a question, make sure you include a CREATE TABLE... statement and INSERT INTO... statement into that table to give the volunteers here representative data. with your description of the problem, we can provide a tested, verifiable solution to your question! asking the question the right way gets you a tested answer the fastest way possible!

Viewing 2 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic. Login to reply