Failed to enable constraints on varchar data?

  • I have a table for forum posts in my SQL 2005 Database...

    Everything works wonderfully and has for months except sometimes I get an error after a new post is made. The error is "Failed to enable constraints. One or more rows contain values violating non-null, unique, or foreign-key constraints." This is a varchar(5000) field.

    I am unable to identify the cause since it rarely occurs. The field is populated via a Textbox in an ASP.Net 2.0 website form.

    One thing I know that causes the error is a carriage return. If I type in any lengthy text and have more than 1 paragraph, this will cause the error.

    I have no idea what caused the latest error. It was just a single paragraph about 500 characters long. It had spaces, alphanumeric, $ signs, commas, a single dash, and periods.

    All responses appreciated!

  • From the error and your description, do you have some type of constraint on the column or table that prevents non-printing characters or something? Simply storing a carriage return is not an issue normally.

    "The credit belongs to the man who is actually in the arena, whose face is marred by dust and sweat and blood"
    - Theodore Roosevelt

    Author of:
    SQL Server Execution Plans
    SQL Server Query Performance Tuning

  • Is it possible that the insert statement is set up in such a way that it's trying to insert twice with the same ID/PK value in those cases?

    (I'm guessing based on the error message. Without the table structure and the insert proc, that's the best I can do.)

    - Gus "GSquared", RSVP, OODA, MAP, NMVP, FAQ, SAT, SQL, DNA, RNA, UOI, IOU, AM, PM, AD, BC, BCE, USA, UN, CF, ROFL, LOL, ETC
    Property of The Thread

    "Nobody knows the age of the human race, but everyone agrees it's old enough to know better." - Anon

  • I discovered that my Object Data Source in my app had held an old l;imit of 500 character instead of the 5000.

    Regardless, I still am wondering how I can retain a carriage return in a varchar field populated through a textbox control on a asp,net web page.

Viewing 4 posts - 1 through 3 (of 3 total)

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