Unicode characters require twice the storage space, as each character is converted into a 16-bit number that can be easily stored in any computer system. This is crucial, as it removes the real-world language barrier by encoding every character using a uniform standard.
All these data types “nchar”, “nvarchar”, “nvarchar(max)”, and “ntext” behave the same as “char”, “varchar”, “varchar(max)”, and text respectively.
These data types are used to store characters of various languages, such as Arabic and German.
Data Type
Type
Maximum Size
nchar
Fixed length
4000 characters
nvarchar
Variable length
4000 characters
nvarchar(max)
Variable length
2^31-1 bytes or 1,073,741,822 characters
ntext
Variable length
2^31-1 bytes or 1,073,741,822 characters
Binary Data Types
Data Type
Type
Maximum Storage
Example
binary
Fixed length
8000 bytes
IPv4 binary(2)
varbinary
Variable length
8000 bytes
IP_Address varbinary(4)
varbinary(max)
Variable length
2GB
PDF varbinary(max)
image
Variable length
2GB
Photo image
Date and Time Data Types
Data Type
Description
Range
Example
date
Used to store the date in the YYYY-MM-DDformat.
The value of the year should range from zero to 9999; for month it should be from one to 12, and for day, it should be from one to 31.
The date 12th June 2020 will be stored as ”date 2020-06-12”.
time
Used to store time in the HH:MI:SS format.
Hour should be between zero and 23, minute value between 00 and 59, and the second value between 00 and 61.999999.
5:30 p.m. will be represented as ”time 17:30:00”.
datetime
Used to store both date and time information together in the YYYY-MM-DD HH:MI:SS format.
The date and time portion follows the “date” and “time” data type rules, respectively.
9:15 p.m. 23rd January 2019 will be stored as “datetime 2019-01-23 21:15:00”.
timestamp
Used to store both date and time information together in the YYYY-MM-DD HH:MI:SS format.
‘1970-01-01 00:00:01’ UTC to ‘2038-01-19 03:14:07’ UTC.
9:15 p.m. 23rd January, 2019 will be stored as “datetime 2019-01-23 21:15:00”.
year
Used to store the year in a two-digit or four-digit format.
For the two-digit format, the range is from 1901 to 2155, and for the four-digit format, it is from 1970 to 2069.
The year 2020 will be represented as “year 2020” in the four-digit format and as “year 20” in the two-digit format.