简体   繁体   English

NVARCHAR(MAX)替换TEXT数据类型?

[英]NVARCHAR(MAX) to replace TEXT datatype?

I have read about Are there any disadvantages to always using nvarchar(MAX) and varchar(max) vs varchar(255) from different forums. 我已经读过有关总是在不同论坛中使用nvarchar(MAX)varchar(max)vs varchar(255)的 任何缺点 Now, I wonder if it is ideal/safe practice to convert a text datatype to nvarchar(MAX) ? 现在,我想知道将text数据类型转换为nvarchar(MAX)是否理想/安全 Are there any performance difference? 有没有性能差异? or do I need to specify the size (as in nvarchar(255) ) instead of nvarchar(max) ? 或者我是否需要指定大小(如nvarchar(255) )而不是nvarchar(max)

Answer is very simple: text type is deprecated. 答案很简单:不推荐使用text类型。 So, yes, you should convert a text datatype to varchar(MAX) . 所以,是的,您应该将text数据类型转换为varchar(MAX)

https://msdn.microsoft.com/en-AU/library/ms187993.aspx https://msdn.microsoft.com/en-AU/library/ms187993.aspx

ntext, text, and image data types will be removed in a future version of Microsoft SQL Server. 将来的Microsoft SQL Server版本中将删除ntext,text和image数据类型。 Avoid using these data types in new development work, and plan to modify applications that currently use them. 避免在新的开发工作中使用这些数据类型,并计划修改当前使用它们的应用程序。 Use nvarchar(max), varchar(max), and varbinary(max) instead. 请改用nvarchar(max),varchar(max)和varbinary(max)。

On top of that, if you know that the size of your text is less than 8000, then use varchar(nnn) instead of varchar(max) . 最重要的是,如果您知道text的大小小于8000,则使用varchar(nnn)而不是varchar(max) varchar(nnn) is more efficient than varchar(max) . varchar(nnn)varchar(max)更有效。

Note: text type is for non-unicode text, so use varchar instead. 注意: text类型用于非unicode文本,因此请改用varchar ntext is for unicode text, so use nvarchar instead. ntext用于unicode文本,因此请改用nvarchar

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

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