October 4, 2004 at 2:11 pm
I have a varchar field set to a length of 250. The TSQL book I have says that the maximum length of a varchar field is 255. Due to the input of some users, I need to increase the length significantly. I have seen references on this board to varchar lengths in excess of 255, so I'm confused. What's the real maximum?
October 4, 2004 at 2:20 pm
i think its up to 8000.
******************
Dinakar Nethi
Life is short. Enjoy it.
******************
October 4, 2004 at 3:39 pm
Yes, it is 8000 chars now. You must have an old book as this was the limit in SQL 6.5.
nvarchar is limited to 4000 chars as each char takes 2 bytes.
October 5, 2004 at 6:22 am
The upper limit is 8092 bytes (nence nvarchar is 4046 characters of two bytes each) which is the maximum length of a record, but any other fields have to fit in this as well. If, say, you have two varchar fields of 5000 each, you will get a warning when you create the table but you are OK so long as the total length of the actual data in the record stays below 8093. However, unless you have some very strong validation, it is not a good thing to do.
Do remember that there is a connection setting which specifies the maximum display length of queries and may lead you to believe that data is being truncated when it is not. In Query Analyser, go to Tools/Options/Results tab and look at the setting for Maximum Characters Per Column. This defaults to 256.
October 5, 2004 at 6:43 am
Here is a link to update your books online which it seems might be out of date.
It was in the SQLServerCentral 7/15 issuse.
Enjoy.
Kris
October 5, 2004 at 7:46 am
thanks for all the feedback. it is very helpful.
October 6, 2004 at 11:18 am
Have a look on this page; here you have all data types listed:
Viewing 7 posts - 1 through 6 (of 6 total)
You must be logged in to reply to this topic. Login to reply