Max text length in SQL

Started by
2 comments, last by oneillci 22 years, 6 months ago
I want to have a table in my database that holds more that 255 chars. But this is the max allowed for the varchar and char datatypes. What should I use? There is a text type but I''m having trouble using updatetext and writetext. There must be some way because some of the responses in these forums have more that that. Any help is much appreciated, Thanks, Ciaran
Advertisement
I guess that this is going to depend on which DB you are using. SQL Server has the following limits for it''s fixed and variable length character fields.

Non-Unicode
char 1-8000
varchar 1-8000

Unicode
nchar 1-4000
nvarchar 1-4000


I assume Oracle has the same limits, but am prepared to be wrong about this. I only use SQL Server these days.
Ummm, I use text fields literally every day, and I never have to use anything like updatetext and writetext. Just create your table in the db with a text field and shove your data into it via a simple SQL statement.
insert into mytable values (0, ''This is a whole bunch of text'');
Not much more to it man.

"So crucify the ego, before it''s far too late. To leave behind this place so negative and blind and cynical, and you will come to find that we are all one mind. Capable of all that''s imagined and all conceivable."
- Tool

"There is no reason good should not triumph at least as often as evil. The triumph of anything is a matter of organization. If there are such things as angels, I hope that they're organized along the lines of the mafia." -Kurt Vonnegut
You don''t need to do anything special with the TEXT type. It usually has a limit of something like 65K. Some databases (notibly the free ones) have more types which have different limits on TEXT field sizes.

The following should work no trouble:

  CREATE TABLE MyTable ( MyField TEXT )INSERT INTO MyTable VALUES ( ''A great big long text string that is up to 65K characters.'' )  


codeka.com - Just click it.

This topic is closed to new replies.

Advertisement