Click here to Skip to main content
15,891,372 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have table, in which i want to add some variable sized field.

if i use varchar(X) it will always use X amount of space..

the data that have to be inserted in this field can vary from 10 bytes to few MBs..

this field i wants to store webpage data..

m confused abt an appropriate datatype for this field..

How can i do it?
Posted

1 solution

varchar [ ( n | max ) ]

Variable-length, non-Unicode string data. n defines the string length and can be a value from 1 through 8,000. max indicates that the maximum storage size is 2^31-1 bytes (2 GB). The storage size is the actual length of the data entered + 2 bytes. The ISO synonyms for varchar are char varying or character varying.
So X in varchar(X) specifies the maximum length of the string that can be entered into the field; but it does not mean that X amount of space is always allocated per record. Only the space needed to store the string placed in the field is allocated.
In your case if you are storing more than 8000 characters use varchar(max).
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900