SQL Server Developer Center > SQL Server Forums > SQL Server Express > string or binary data would be truncated error when using varbinary(MAX)
Ask a questionAsk a question
 

Answerstring or binary data would be truncated error when using varbinary(MAX)

  • Friday, November 06, 2009 6:04 AMamarti44 Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     
    I'm using sql server express 2008. I have a table:

    CREATE

     

    TABLE [dbo].[TImage](

    [Name] [varchar]

    (50) NOT NULL,

    [Data] [varbinary]

    (max) NOT NULL,

     

    CONSTRAINT [PK_TImage] PRIMARY KEY CLUSTERED

    I'm trying to insert binary data (around 100K bytes) and I'm getting the error "string or binary data would be truncated. The statement has been terminated."

    Any thoughts?

    Thanks in advance

    Alberto

Answers

All Replies

  • Friday, November 06, 2009 7:25 AMLekssAnswererUsers MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     Answer
    Seems like a workaround is explained in this page http://www.dotnetspider.com/resources/30543-SQL-Error-String-or-binary-data-would-be.aspx
    Thanks, Leks
  • Friday, November 06, 2009 7:29 AMMelissa Suciadi Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     
    hmm that's strange cause when you assign it to varbinary(max) it could store 2^31 =2 147 483 648 bytes. way bigger than 100K bytes
    varbinary [ ( n | max ) ]

    Variable-length binary data. n can be a value from 1 through 8,000. max indicates that the maximum storage size is 2^31-1 bytes. The storage size is the actual length of the data entered + 2 bytes. The data that is entered can be 0 bytes in length. The ANSI SQL synonym for varbinary is binary varying .


    could you supply us the data u're trying to insert


    how about the name data, are you trying to insert it with something more than 50 char length?

    Best Regards,
    Melissa Suciadi


    If you have found this post helpful, please click the 'Vote as Helpful' link (the green triangle and number on the top-left).

    If this post answers your question, click the 'Mark As Answered' link below. It helps others who experience the same issue in future to find the solution.