Skip to content
Related Articles

Related Articles

Improve Article
Save Article
Like Article

Difference between char and nchar : MS SQL Server Datatypes

  • Last Updated : 14 Sep, 2020

A database has a vast collection of data stored in an organized format. A database might contain a variety of data values stored in it. To avoid confusions, the data values are assigned a name based on its type. These are called datatypes. Datatypes help the users distinguish between different categories of data. MS SQL Server supports a wide range of datatypes for the users to be able to easily identify various categories of data and to use it accordingly.

1. Char :
A character is a string of words dentod by single quotation marks. Character is shortened to char in MS SQL Server. It is a datatype that stores only non-unicode data. Non-unicode data is a format that doesn’t support the unicode standards. It takes 1 byte of data and the maximum storage capacity is of 8000 bytes.

Syntax –

column_name char(number _of_bytes);

2. n-char :
A n-char is also a string of words that can store unicode data. nchar stands for national character. It takes up two bytes to store the data and can store upto 4000 chars. Unicode data refers to a universal coding standard for letters and other data. Each one is uniquely identified by designating a numeric value.

Syntax –

column_name nchar(number_of_bytes);

Difference between char and nchar : MS SQL Server Datatypes :

A char stores fixed-length, non-unicode characters.A n-char stores fixed-length unicode characters.
One byte to store the data.Two bytes to store data.
char stores upto 8000 bytes.n-char stores upto 4000 bytes.
It is widely preferred datatype.It is preferred less.
It uses Unicode standards for storing the data.It uses ASCII standards to store the data.

Syntax :

col_name char(n); 

*n is the number of bytes.

Syntax :

col_name nchar(n); 

*n is the number of bytes.

The number of bytes is not mandatory to specify. It automatically takes the default value of 1 and converts it in ASCII format.The letter n(national) in nchar has to be specified in order to convert the data in Unicode format.

My Personal Notes arrow_drop_up
Recommended Articles
Page :

Start Your Coding Journey Now!