Attempt to update ntext field

  • I have a string that's about 5000 characters in length, and I need to store it in a database table.  The field in the table I want to store it in used to be nvarchar, but the data was too large, so I changed it to ntext.

    Now, I absolutely cannot store more than 4000 characters in this field, no matter what I do.

    I tried running a query and hardcoding my data into the query, and it came back and said "String or binary data would be truncated".

    I tried writing a stored procedure and executing it from the Management Studio, and same error.

    Finally, I tried writing a small .NET application that reads the data in from a file, and calls the stored procedure, eliminating the step of "hard-coding" the string.  This also produced the same error.

    I am stumped.  Is there only really a 4K limit on ntext size, or ...???

    Thanks,

    Cynthia

  • Why not change it to varchar(max) or nvarchar(max)?

    As far as  your current problem, read up on how to handle large text strings in text fields.  I THINK a regular insert only handles up to 8000 bytes.

     

    Edit: see the Writetext article in Books Online.

  • I did try nvarchar(max), and still it would only allow 4000 characters.  That made me assume that the "max" was 4000.

    I will check books online and see what they say.

  • Are you sure it is in the table you are trying to insert that is throwing that message?  How about a variable somewhere?  Or a trigger?

  • Oops -- dumb error!  I was trying to update a table that had nvarchar(4000) instead of the one with ntext. It actually does work with nvarchar(max).

    Never mind!

     

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

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