ntext、text 和 image (Transact-SQL)ntext, text, and image (Transact-SQL)

适用对象:是SQL Server 是Azure SQL 数据库 否Azure Synapse Analytics (SQL DW) 否并行数据仓库APPLIES TO: yesSQL Server yesAzure SQL Database noAzure Synapse Analytics (SQL DW) noParallel Data Warehouse

用于存储大型非 Unicode 字符、Unicode 字符及二进制数据的固定长度数据类型和可变长度数据类型。Fixed and variable-length data types for storing large non-Unicode and Unicode character and binary data. Unicode 数据使用 UNICODE UCS-2 字符集。Unicode data uses the UNICODE UCS-2 character set.

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

参数Arguments

ntextntext
长度可变的 Unicode 数据,字符串最大长度为 2^30 - 1 (1,073,741,823) 个字节。Variable-length Unicode data with a maximum string length of 2^30 - 1 (1,073,741,823) bytes. 存储大小是所输入字符串长度的两倍(以字节为单位)。Storage size, in bytes, is two times the string length that is entered. ntext 的 ISO 同义词为 national text 。The ISO synonym for ntext is national text.

texttext
服务器代码页中长度可变的非 Unicode 数据,字符串最大长度为 2^31-1 (2,147,483,647) 个字节。Variable-length non-Unicode data in the code page of the server and with a maximum string length of 2^31-1 (2,147,483,647). 当服务器代码页使用双字节字符时,存储仍是 2,147,483,647 字节。When the server code page uses double-byte characters, the storage is still 2,147,483,647 bytes. 根据字符串,存储大小可能小于 2,147,483,647 字节。Depending on the character string, the storage size may be less than 2,147,483,647 bytes.

图像image
长度可变的二进制数据,从 0 到 2^31-1 (2,147,483,647) 个字节。Variable-length binary data from 0 through 2^31-1 (2,147,483,647) bytes.

RemarksRemarks

以下函数和语句可与 ntext、text 或 image 数据一起使用 。The following functions and statements can be used with ntext, text, or image data.

函数Functions 语句Statements
DATALENGTH (Transact-SQL)DATALENGTH (Transact-SQL) READTEXT (Transact-SQL)READTEXT (Transact-SQL)
PATINDEX (Transact-SQL)PATINDEX (Transact-SQL) SET TEXTSIZE (Transact-SQL)SET TEXTSIZE (Transact-SQL)
SUBSTRING (Transact-SQL)SUBSTRING (Transact-SQL) UPDATETEXT (Transact-SQL)UPDATETEXT (Transact-SQL)
TEXTPTR (Transact-SQL)TEXTPTR (Transact-SQL) WRITETEXT (Transact-SQL)WRITETEXT (Transact-SQL)
TEXTVALID (Transact-SQL)TEXTVALID (Transact-SQL)

另请参阅See also

CAST 和 CONVERT (Transact-SQL)CAST and CONVERT (Transact-SQL)
数据类型转换(数据库引擎)Data Type Conversion (Database Engine)
数据类型 (Transact-SQL)Data Types (Transact-SQL)
LIKE (Transact-SQL)LIKE (Transact-SQL)
SET @local_variable (Transact-SQL)SET @local_variable (Transact-SQL)
排序规则和 Unicode 支持Collation and Unicode Support