Collections:
Unicode Character Data Types in SQL Server Transact-SQL
What are Unicode character string data types supported in SQL Server Transact-SQL?
✍: FYIcenter.com
Unicode character string data types are used to hold Unicode character strings.
There are 3 Unicode character string data types supported in SQL Server Transact-SQL:
1. NCHAR (or NATIONAL CHAR, or NATIONAL CHARACTER) - Used to hold Unicode character strings of a fixed length specified in the format of NCHAR(n), where n defines the string length as number of characters. The maximum length of VARCHAR is 4,000 Unicode characters.
The storage size of VARCHAR(n) is fixed to 2*n bytes, regardless of the length of the string value. Each Unicode character is stored in UTF-16 2-byte encoding.
2. NVARCHAR (or NATIONAL CHAR VARYING or NATIONAL CHARACTER VARYING) - Use to hold Unicode character strings of variable lengths, specified in the format of NVARCHAR(n), where n defines the string length as number of characters. The maximum length of NVARCHAR is 4,000 Unicode characters.
The storage size of NVARCHAR(n) is flexible up to 2*n+2 bytes, depending on the length of the string value. The extra 2 bytes are used to store the length of the string value.
3. NTEXT (or NVARCHAR(MAX), or NATIONAL TEXT) - Use to hold Unicode character strings of very large lengths. NTEXT uses the CLOB (Character Large OBject) technology to store string values. NTEXT can store string values of variable lengths up to 2^30-1 (1,073,741,823) characters.
Here are some good examples of Unicode character string values:
PRINT N'Hello! '; -- NCHAR(10) PRINT N'Hello!'; -- NVARCHAR(10) PRINT CAST(N'Hello!' AS BINARY(10)); ---------------------- Hello! Hello! 0x480065006C006C006F00
⇒ Differences of CHAR and NCHAR in SQL Server Transact-SQL
⇐ Single-Byte Character Data Types in SQL Server Transact-SQL
2017-04-08, 2014🔥, 0💬
Popular Posts:
How To Create a Dynamic Cursor with the DYNAMIC Option in SQL Server Transact-SQL? If the underlying...
How To Set Up SQL*Plus Output Format in Oracle? If you want to practice SQL statements with SQL*Plus...
What Happens If the UPDATE Subquery Returns Multiple Rows in SQL Server? If a subquery is used in a ...
How To Start MySQL Server in MySQL? If you want to start the MySQL server, you can run the "mysqld" ...
What Are Out-of-Range Errors with DATETIME values in SQL Server Transact-SQL? When you enter DATETIM...