简体   繁体   English

SQL:最大(n)varchar大小可以存储在sql_variant中

[英]SQL: Maximum (n)varchar size can be stored in sql_variant

I know that sql_variant cant hold items of size nvarchar(max) . 我知道sql_variant不能容纳大小为nvarchar(max) Which is the maximum size of nvarchar or varchar that sql_variant can hold? sql_variant可以容纳的nvarcharvarchar的最大大小是多少?

sql_variant can have a maximum length of 8016 bytes. sql_variant的最大长度为8016字节。 This includes both the base type information and the base type value. 这包括基本类型信息和基本类型值。 The maximum length of the actual base type value is 8,000 bytes. 实际基类型值的最大长度为8,000字节。

From Microsoft docs. 来自Microsoft docs.

as pulled from Microsoft 微软拉出来

sql_variant can have a maximum length of 8016 bytes. sql_variant的最大长度为8016字节。 This includes both the base type information and the base type value. 这包括基本类型信息和基本类型值。 The maximum length of the actual base type value is 8,000 bytes. 实际基类型值的最大长度为8,000字节。

to answer your question more you can have a varchar of 8k length or a nvarchar of 4k length. 为了回答你的问题,你可以有8k长的varchar或4k长的nvarchar。

As the above documentation points out the output will never be larger then 8,000 bytes. 正如上面的文档所指出的那样,输出永远不会超过8,000字节。

more info on varchar and nvarchar 有关varchar和nvarchar的更多信息

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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