It is not clear to me how a varchar(max)
is declared or used in an SQL Server e.g. 2005
Is a variable declared as varchar(300000)
for example considered as a varchar(max)
?
E.g. I am seeing in a DB in a table a variable is declared as varchar(8000)
.
Can I simply increase it to varchar(300000)
?
Thanks
When you define a maximum size explicitly, then you cannot define higher than
CHAR(8000)
/VARCHAR(8000)
orNCHAR(4000)
/NVARCHAR(4000)
.When you define a variable as
CHAR(max)
orVARCHAR(max)
, you set the maximum size of that variable to2GB
.There is no way to define a variable with a maximum size between
8000 bytes
and2GB
.No, you cannot. The max size for varchar on SQL server is 8000. If you want something bigger you need to use a different type, such as ntext or text .
Then, to find the length of data you have stored, you can do this: