简体   繁体   中英

T-sql COLLATE and Varchar(max)

When u use Varchar(max), it is 8000 chars for a variable, and around 2^32 for a column, what is COLLATE and how it affects that?

Thanks

Collation deterines how SQL Server sorts and compares string data (which varchar variables and column values are).

See here

When you declare a column or a variable of varchar(max) , it can take up to 2 GB of data and 2^31-1 characters. If you declare the column or variable as nvarchar , it can still only take 2 GB of data and (2^31-1) / 2 characters since each character takes up twice as much space. When you declare a varchar column or variable without the use of the COLLATE clause, the collation of the database is used. The ``COLLATE clause does not affect the capacity of the column or variable.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM