Which data type to use - Truncation errors

Results 1 to 3 of 3

Thread: Which data type to use - Truncation errors

  1. #1
    Join Date
    Dec 1969

    Default Which data type to use - Truncation errors

    I have a text area on a form that once submitted is inserting into a sql 2000 database. If someone enters a large amount of text they will receive a truncation error. I am currently using the data type varchar with 4000 max characters. My question is: Is varchar the best data type to use when storing a large amount of text? Is 4000 characters the most you can store in one field?

  2. #2
    Join Date
    Dec 1969

    Default I may be mistaken

    .. but i think that &#039;nvarchar&#039; would probably serve you best. In the event that your text is only 300 chars then that is all the space it would store with a end character. And yes 4000 is the max...<BR><BR>sponge

  3. #3
    Join Date
    Dec 1969

    Default yes you are, sorry

    the difference between varchar and nvarchar is that nvarchar stores unicode data (and consuming twice the space of varchar!)<BR><BR>The difference where sponge is talking about is the difference between CHAR,NCHAR and NVARCHAR,VARCHAR. The VARCHAR type consumes space for the actual data stored and CHAR consumes all the space you allocate for it. So CHAR(100) consumes 100 bytes.<BR><BR>The maxlenght for a (n)varchar column is about 8000 characters. If you need more you could use (n)text, but that datatype has some difficulties you really don&#039;t want to deal with if you don&#039;t need to.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts