none
Msg 8152:String or binary data would be truncated

    Question

  • I am getting this error

    Msg 8152, Level 16, State 14, Line 1

    String or binary data would be truncated.

    The statement has been terminated.

    AND

    I am using this query:

    INSERT INTO WSD.dbo.TRANSFERHISTORY 

    (FROMAGENCYID, FROMSERVICESITEID, TOAGENCYID, TOSERVICESITEID, WI_ID, MODIFYDTTM, MODIFYUSERID)

    SELECT FROM_AGENCY_ID, FROM_CLINIC_CODE, TO_AGENCY_ID, TO_CLINIC_CODE, ID_NUMBER, LAST_UPDATE_DATE, LAST_UPDATE_BY FROM 

    WSDCO.dbo.BOOKMARK

    I think its related to the Length of the data type ID_NUMBER varchar(9) and WI_ID varchar(8). 

    So what is the solution for this???


    dimrd_SQL
    Monday, February 28, 2011 5:23 PM

Answers

  • You can use LEFT(ID_NUMBER,8) instead of ID_NUMBER if you can not fix the structure of the TransferHistory table to match your other table structure exactly.
    Premature optimization is the root of all evil in programming. (c) by Donald Knuth

    Naomi Nosonovsky, Sr. Programmer-Analyst

    My blog
    • Marked as answer by Ai-hua Qiu Tuesday, March 08, 2011 7:46 AM
    Monday, February 28, 2011 5:30 PM

All replies