varchar, varchar(max) and nvarchar in MS SQL Server

We know that a database can different datatypes. Consider an organization having various databases like Employees, Departments, Finance. The employee database has a table that stores the details of each employee and employee is uniquely identified using the employee ID.

In most of the cases, an employee ID has a combination of digits and letters. How can the database store the values? It uses a special datatype named varchar or Variable Character datatype. It uses numbers and letters.

  1. varchar :
    Variable Character or varchar for short is a datatype that stores non-Unicode data.
    The syntax for varchar is:
    Syntax :

    varchar (n)

    n – is the number of bytes. The maximum storage capacity is upto 8000 bytes.

  2. varchar(max) :
    It stores character string data of maximum storage size 2³¹-1 bytes.

    Syntax :

  3. nvarchar :
    This stores variable length unicode data.
    Syntax for nvarchar is:
    Syntax :


    n – is the number of bytes and can store upto 4000 bytes. If the length for the datatype isn’t specified, it takes the default value of 1. These datatypes can be used while creating a table.

An overview of these datatypes :

Characteristics varchar varchar(max) nvarchar
Storage It stores variable length, non unicode character string data. It stores variable length non-unicode, character string data. It stores variable length, unicode character string data.
Syntax varchar(n)

*n is the number of bytes


*max is the maximum storage value.


*n is the number of bytes.

Storage size 1-8000 bytes 2³¹-1 bytes 1-4000 bytes

My Personal Notes arrow_drop_up

If you like GeeksforGeeks and would like to contribute, you can also write an article using or mail your article to See your article appearing on the GeeksforGeeks main page and help other Geeks.

Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.

Article Tags :
Practice Tags :

Be the First to upvote.

Please write to us at to report any issue with the above content.