I would like to know what is the maximum size of varchar
in SQL Server 2000. While I was googling somewhere it was written 8000 characters and somewhere it was written 8060 bytes. Which one is correct?
相关问题
- sql execution latency when assign to a variable
- What is the best way to cache a table from a (SQL)
- php PDO::FETCH_ASSOC doesnt detect select after ba
- Bulk update SQL Server C#
- SQL to Parse a Key-Value String
相关文章
- Entity Framework 4.3.1 failing to create (/open) a
- Code for inserting data into SQL Server database u
- Delete Every Alternate Row in SQL
- Linux based PHP install connecting to MsSQL Server
- SQL Azure Reset autoincrement
- How do we alias a Sql Server instance name used in
- Is recursion good in SQL Server?
- How can I convert a OLE Automation Date value to a
A SQL Server data page has 8k: 8192 bytes. From this a portion is reserved for the page header, leaving 8060 bytes the maximum lnegth a single row can have. In a row, the varbinary(n), varchar(n) and nvarchar(n) types cannot exceed 8000 bytes, which means that varchar(8000) is the maximum Ascii length and nvarchar(4000) is the maximum Unicode length (since Unicode stores each character on 2 bytes).
The best explanation of all these details comes from Inside the Storage Engine: Anatomy of a page.
Varchar is 8000 and nvarchar is 4000.
Here's the varchar msdn reference:
http://msdn.microsoft.com/en-us/library/aa258242(SQL.80).aspx
As far as I remember it is 8000 Chars.
For Nvarchar it is 4000.
The maximum size of varchar(max) is large (2GB or 2Gchars, I think). The maximum value you can specify for n in varchar(n) is 8000, and for nvarchar it's 4000.