none
Error 8152: "String or binary data would be truncated"

    Question

  • I've been working with a sample database that the company is using for testing purposes. I (we) did not create the database - it was sent over to us by another company. I'm still a rank newbie at working with MS SQL Server, though I've worked with Access and MySQL in the past.

    There is one table that contains bank information. At the moment, it is filled with information on imaginary (fake) banks. I need to change one record so that it contains the information of a real bank the company is using.

    The problem is, I am unable to touch anything within this table. Any attempt to make changes gives me an error prompt that reads "String or binary data would be truncated". I ran the profiler, and it shows an Exception - Error: 8152 Severity 16 State 2.

    Furthermore, I also get an error prompt stating: "The value you entered is not consistent with the data type or length of this column".

    I've checked and checked again, and as far as I can tell, the value I entered _is_ consistent with the data type/length of the column.

    I can make changes perfectly fine on the other tables in the database. Only this one table gives me trouble.

    Could anyone shed some light on why exactly this is occurring, and why only on this one table?

    Thank you :)
    Monday, October 17, 2005 9:22 PM

Answers

  • in order to shed some light, you would need to show us the schema and the statement you're issuing that's causing the failure.

    also check if there are triggers on the table, if so, you should check out the code of those as well.
    Friday, October 21, 2005 1:17 AM

All replies

  • in order to shed some light, you would need to show us the schema and the statement you're issuing that's causing the failure.

    also check if there are triggers on the table, if so, you should check out the code of those as well.
    Friday, October 21, 2005 1:17 AM
  • Greg - I just had to say thanks.  I've been trying to figure out my own similar problem for (way too many) hours.  When you mentioned "triggers" a light went on and led me to the source of the problem - a field updated by a trigger was indeed too small.  Now I can get some sleep. THANK-YOU!
    Randy
    Tuesday, October 25, 2005 5:03 AM
  • Make sure that [Table] and ]TableX] are the same type and lenght.

    I was getting the same error and I found out that the filed length was different in one table then another table that had the foreign key of the first table.

     

    For example accountnumber field in the statement table was 400 but in statementx table it was set to 255.  After I changed the accountnumber field in the statementx table to 400 the problem fixed.

    Thursday, November 10, 2005 3:05 PM
  • Hi Greg,

    Have you ever seen this error occur on few (not all) records that been tried?

    Here's the trigger code that get's called to archive the original data after it's been changed:

    CREATE TRIGGER dbo.tuASSIGNMENT
    ON dbo.ASSIGNMENT
    AFTER UPDATE, DELETE AS

    INSERT ASSIGNMENTHISTORY(assignmentID,
                             assignmentName,
                             assignmentDesc,
                             assigneeID,
                             assignDate,
                             dueDate,
                             completeDate,
                             crUser,
                             updUser,
                             updDate,
                             disposition)

    SELECT assignmentID,
           assignmentName,
           assignmentDesc,
           assigneeID,
           assignDate,
           dueDate,
           completeDate,
           crUser,
           user,
           getdate(),
           disposition
    FROM   deleted

    And here's the stored procedure code that works on all cases when executed directly on the SQL Server box, but blows up with the error occasionally when called with the same parameters from an Access 2002 form.  All of the parmeter values are passed and read okay.

    CREATE PROCEDURE dbo.updPROJECTtoNewDirector
    (@oldID int,
     @newID int,
     @assmtID int)

    AS

    UPDATE ASSIGNMENT
    SET    assigneeID = @newID
    WHERE  assigneeID = @oldID
    AND    assignmentID = @assmtID

    Thanks,

                 Mark

    Thursday, December 29, 2005 10:20 PM
  • In this case, it seems that Access 2002/VBA was having trouble with the trigger's behavior.  When I diabled the trigger, all of the records that were showing up with the Error 8152 were suddenly updating ok.  Bizarre behavior, but that's Access VBA for ya!

    Happy New Year to all!

    Friday, December 30, 2005 8:08 PM
  • I got this same error.

    The reason I got it was that I had created a temp table and in that table definition one of my varchar columns was too small (it was a temp table).  I doubled the size in the definition and  it worked.

    Although it may not be the solution to your problem, anyone coming here for the same problem might want to start here as it's quick thing to try.

    Tuesday, March 25, 2014 3:58 PM