Size limit of varchar(MAX) in SQL Server

frenchie

I have a row that contains a field defined as varchar(MAX). I'm confused about the limit of the field: in some places, I read that varchar(MAX) has a size limit of 8K and in other places it seems that the limit is 2GB.

I have a string that I want to save to a database; it's about 220K. I'm using linq-to-sql and when the write query submits to the database, the row gets written without any exceptions generated. However, when I open the database table in SSMS, the cell that should contain the long string is empty. Why is that and how do I take advantage of the 2GB limit that I read about?

This is the property in the linq-to-sql model:

enter image description here

Solomon Rutzky

All MAX datatypes--VARCHAR(MAX), NVARCHAR(MAX), and VARBINARY(MAX)--have a limit of 2 GB. There is nothing special you need to do. Without specifying MAX, the limit for VARCHAR and VARBINARY are 8000 and the limit for NVARCHAR is 4000 (due to NVARCHAR being double-byte). If you are not seeing any data come in at all, then something else is going on.

Are you sure that the column is even in the INSERT statement? If you submit test data of only 20 characters, does that get written? If you want to see what SQL is actually submitted by Linq, try running SQL Profiler and look at the SQL Statement: Statement Ended event, I believe.

Also, when you say that the "long string is empty", do you mean an actual empty string or do you mean NULL? If it is not NULL, you can also wrap the field in a LEN() function to see if there are blanks for returns at the beginning that push any non-whitespace characters out of view. Meaning, SELECT LEN(stringField), * FROM Table. Another thing to try is to use "Results to Text" instead of "Results to Grid" (this is a Query option).

EDIT:
Seeing that the field is marked as NOT NULL, are you sure that you are setting the ClientFileJS property of your object correctly? Is it possible that the empty string is due to that property being initialized as string ClientFileJS = ""; and is never updated?

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

Transaction Size Limit in SQL Server

From Dev

Size limit of varchar(MAX) in SQL Server

From Dev

Sql Server row size limit and table design

From Dev

Sql Server Express db size limit

From Dev

Sql Server row size limit and table design

From Dev

SQL Server OFFSET and LIMIT

From Dev

How to check if my SQL Server Express database exceeds the 10 GB size limit?

From Dev

How to check if my SQL Server Express database exceeds the 10 GB size limit?

From Dev

Ajax post to web server: size limit error

From Dev

Ghost Records and MS Sql Express size limit

From Dev

Google Cloud SQL row size limit

From Java

Select SQL Server database size

From Dev

Microsoft SQL Server column size

From Dev

Microsoft SQL Server column size

From Dev

Maximum size of IN expression SQL Server

From Dev

Forecasting the DB size in SQL Server

From Dev

Is there a limit to the number of tables in a SQL Server database AND view?

From Dev

SQL Server 2012 Equivalent limit Pagination

From Dev

Is there an equivalent MYSQL "LIMIT" Clause in SQL Server?

From Dev

SQL server - Limit search to a maximum value in a column

From Dev

LIMIT equivalent for SQL Server 2012 in an UPDATE statement

From Dev

SQL Server select queries union all and limit

From Dev

Add LIMIT to INNER JOIN (SQL Server)

From Dev

Execute SQL Task - Any limit on the size of result set?

From Dev

SQL: Limit the number of row can be queried in SQL Server

From Dev

Entity Framework - SQL Query - Limit and Order By - SQL Server

From Dev

How the size of SQL server be allocated for each database in SQL server 2012?

From Dev

SQL Server nullable data types size

From Dev

SQL server - Delete statement increase the LOG size

Related Related

HotTag

Archive