简体   繁体   中英

Why CHARACTER_MAXIMUM_LENGTH gives NULL and -1 in sql server table?

sql:

SELECT * FROM INFORMATION_SCHEMA.COLUMNS  for columns like rank(id,null) CHARACTER_MAXIMUM_LENGTH is NULL and for the column id(varchar(max),null) CHARACTER_MAXIMUM_LENGTH is -1.

why cant i get the maximum length for rank(id,null) - 4

A value of -1 means it's a varchar(max) or nvarchar(max) field.

A null value means that it's a number that doesn't have a length.

Numbers are not characters, so they do not have a character_maximum_length .

(max) columns are limited to ~2gb of data (2^31-1 bytes (2 GB)), so however many that is in characters (costs twice as much in bytes per nvarchar() character vs varchar() characters), is represented by -1 .

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