What is the difference between char
, nchar
, ntext
, nvarchar
, text
and varchar
in SQL?
I
N
prefix indicates unicode support and takes up twice the bytes per character of non-unicode.
Varchar
is variable length. You use an extra 2 bytes per field to store the length.
Char
is fixed length. If you know how long your data will be, use char
as you will save bytes!
Text
is mostly deprecated in my experience.
Be wary of using Varchar(max)
and NVarchar(max)
as these fields cannot be indexed.