SQLTeam.com | Weblogs | Forums

T-sql large data size


#1

In sql server 2012, I want to allow a user to enter data into large columns that are used for different types of comments.

The largest varchar field that I am allowed to use is varchar(8000). I do not want to use varchar(max) since that will be deprecated at some point.

The datatypes only need to be used for within the United States (English).

Thus would you let me know what the largest field size is that I can use?


#2

As far as I know, there are no plans to deprecate VARCHAR(MAX). VARCHAR(MAX) was replacement for TEXT. So, if there is a need, I would not hesitate to use VARCHAR(MAX).

If there is some other reason for not using VARCHAR(MAX), the maximum length you can specify is 8000.


#3

Someone's going to type in more than 8,000 chars over and over? Really? Yikes!

Varchar(max) processes slower, but is as easy to use as regular varchar.

Finally, as JamesK noted, text is data type being deprecated, not varchar(max).


#4

If you really do have sizes that go over the 8000k limit, an option is to use sequential rows to insert subsets and concatenate on retrieval. The typical way I have done this is the past is to select a chunk 8000 characters long and find the first space from the tail to end the block. Repeat in a loop until size < 8000. Not pretty SQL or code by any means...