Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations John Tel on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Max length of a varchar field

Status
Not open for further replies.

LonnieJohnson

Programmer
Apr 16, 2001
2,628
US
Ok, here is what may be a stupid question to some, but if you define a column in a table as varchar with a lengh of 8000. Is that 8000 characters or 8000 bytes? I have such a field and it seems like it will not except more than 4000 typed characters from an input form in an application.

Thanks in advance.

ProDev, Builders of Affordable Software Applications
Visit me at ==>
May God bless you beyond your imagination!!!
 
The column will be 8000 bytes. Is the column defined as varchar(8000) or Nvarchar(8000)? If the column is Nvarchar it is Unicode and reserves 2 bytes of storage for each character. If it is varchar, it reserves one byte of storage per character. Is it possible the limitation is a result of the input application?
 
Thanks for the reply. The problem was that the user was typing a long narritive in Word then pasting it into the application. There was formatting and other issues from the word document that made the character count seem higher than what it was.

Thanks again.

ProDev, Builders of Affordable Software Applications
Visit me at ==>
May God bless you beyond your imagination!!!
 
varchar(8000) is 8000 bites, all inclusive.
nvarchar on the other hand, can't be more that 4000 chars just because it keeps double bite chars in it. That is for SQL Server 2000. In SQL Server 2005 you can use varchar(max). That type can have up to 16MB chars, but better check BOL I post that on top of my head.

Borislav Borissov
VFP9 SP2, SQL Server 2000/2005.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top