简体   繁体   English

SQL Server文本,ntext,图像数据类型问题

[英]SQL Server text, ntext, image data type problem

Microsoft announced that: " ntext , text , and image data types will be removed in a future version of Microsoft SQL Server." 微软宣布:“将在未来版本的Microsoft SQL Server中删除ntexttextimage数据类型。” And advises to use nvarchar(max) , varchar(max) , and varbinary(max) instead. 并建议改为使用nvarchar(max)varchar(max)varbinary(max)

My question: I have a data type bigger than 8 kb. 我的问题:我的数据类型大于8 kb。 How can I insert this data to sql? 如何将此数据插入sql? Which data type will solve my problem? 哪种数据类型可以解决我的问题?

MSDN document about data types 关于数据类型的MSDN文档

Any of nvarchar(max) , varchar(max) , and varbinary(max) . nvarchar(max)varchar(max)varbinary(max)中的任何一个

nvarchar(max) and varchar(max) are for textual information (with nvarchar having unicode support). nvarchar(max)和varchar(max)用于文本信息(nvarchar具有unicode支持)。

varbinary(max) is for binary data (images, files etc). varbinary(max)用于二进制数据(图像,文件等)。

In all cases, it is documented that using MAX indicates that the maximum storage size is 2^31-1 bytes. 在所有情况下,记录使用MAX indicates that the maximum storage size is 2^31-1 bytes.

If it is text data then either varchar(max) or nvarchar(max) (supports unicode). 如果是文本数据,则varchar(max)nvarchar(max) (支持unicode)。 varchar(max) has a maximum storage size of 2^31-1 bytes ( Ref .) varchar(max)的最大存储大小为2 ^ 31-1个字节( 参考

If it is binary data then use varbinary(max) . 如果是二进制数据,则使用varbinary(max)

You would use either nvarchar(max) , varchar(max) or varbinary(max) 您可以使用nvarchar(max)varchar(max)varbinary(max)

If you insert data greater than the 8KB row limitation the data is moved off-row to another page in a ROW_OVERFLOW_DATA allocation unit. 如果插入大于8KB行限制的数据,则数据将在行外移动到ROW_OVERFLOW_DATA分配单元中的另一个页面。

The following MSDN article explains this process in further detail. 以下MSDN文章更详细地解释了此过程。

I believe the maximum for varchar(max) is 2GB. 我相信varchar(max)的最大值是2GB。

Don't be confused by the "varchar" bit. 不要被“varchar”位混淆。

It basically means you can use most functions on varchar(max) like you would on varchar(50) or varchar(1000) or varchar(8000)`. 它基本上意味着您可以像在varchar(50) or varchar(1000) or varchar(8000)上一样使用varchar(max)上的大多数函数。

  • The (max) datatypes support 2^32-1 bytes (max)数据类型支持2 ^ 32-1个字节
  • The non-max types support upto 8000 bytes 非最大类型支持最多8000个字节

So you can have varchar(50) or varchar(1000) upto varchar(8000) but for storing longer strings you'd use varchar(max) . 所以你可以让varchar(50)varchar(1000)达到varchar(8000)但是为了存储更长的字符串你需要使用varchar(max)

The "max" or "50"/"1000"/"8000" bit simply determines internal storage + maximum string length. “max”或“50”/“1000”/“8000”位仅确定内部存储+最大字符串长度。

There a few minor differences, such as indexing, of course. 当然,还有一些细微差别,例如索引。

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

相关问题 SQL Server 2016 CTP 3 中的 ntext/text/image 数据类型 - ntext/text/image datatypes in SQL server 2016 CTP 3 ntext,text和image的弃用是否会影响SQL Server Compact Edition? - Does the deprecation of ntext, text, and image affect SQL Server Compact Edition? 如何在SQL Server 2008的存储过程中操作ntext类型数据 - How to manipulate ntext type data in stored procedure of SQL Server 2008 SQL Server 2005和Datanucleus问题(ntext查询) - SQL Server 2005 and Datanucleus problem (ntext query) SQL Server,nvarchar(MAX)或ntext,image还是varbinary? - SQL Server, nvarchar(MAX) or ntext, image or varbinary? 如何克服SQL Server上的“无法获取文本,ntext和图像变量。”? - How to get over “Cannot fetch into text, ntext, and image variables.” on SQL Server? Sql Server CE 3.5和Visual Studio中ntext的大小限制问题 - Size limit problem with ntext in Sql Server CE 3.5 and Visual Studio 在Sql Server中将图像数据类型转换为字符串时的字符问题 - Character Problem When Converting image Data Type to String in Sql Server SQL Server 错误 - 操作数类型冲突:ntext 与 int 不兼容 -(我什至没有使用“ntext”) - SQL Server error - Operand type clash: ntext is incompatible with int - (I'm not even using "ntext") 程序需要“ntext/nchar/nvarchar”类型的参数“@params”SQL 服务器 - Procedure expects parameter '@params' of type 'ntext/nchar/nvarchar' SQL Server
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM