nchar and nvarchar

Transact-SQL Reference

Transact-SQL Reference

nchar and nvarchar

Character data types that are either fixed-length (nchar) or variable-length (nvarchar) Unicode data and use the UNICODE UCS-2 character set.

nchar(n)

Fixed-length Unicode character data of n characters. n must be a value from 1 through 4,000. Storage size is two times n bytes. The SQL-92 synonyms for nchar are national char and national character.

nvarchar(n)

Variable-length Unicode character data of n characters. n must be a value from 1 through 4,000. Storage size, in bytes, is two times the number of characters entered. The data entered can be 0 characters in length. The SQL-92 synonyms for nvarchar are national char varying and national character varying.

Remarks

When n is not specified in a data definition or variable declaration statement, the default length is 1. When n is not specified with the CAST function, the default length is 30.

Use nchar when the data entries in a column are expected to be consistently close to the same size.

Use nvarchar when the data entries in a column are expected to vary considerably in size.

Objects using nchar or nvarchar are assigned the default collation of the database, unless a specific collation is assigned using the COLLATE clause.

SET ANSI_PADDING OFF does not apply to nchar or nvarchar. SET ANSI_PADDING is always ON for nchar and nvarchar.

See Also

ALTER TABLE

CAST and CONVERT

COLLATE

CREATE TABLE

Data Type Conversion

Data Types

DECLARE @local_variable

DELETE

INSERT

LIKE

SET ANSI_PADDING

SET @local_variable

sp_dbcmptlevel

UPDATE

Using Unicode Data

WHERE