It depends on the data type of that column. In SQL Server there are two kinds of character data types — regular and Unicode. Regular data types which are CHAR
and VARCHAR
. Unicode data types like NCHAR
and NVARCHAR
. For regular characters SQL Server uses one byte of storage for each character, whereas Unicode characters NVARCHAR
uses two bytes per character.
You can also get the number of bytes used by a string using DATALEGNTH
or LEN
like so:
SELECT DATALENGTH(inputstring);
As I explained later, If this inputstring
is of type NVARCHAR
or N'string'
DATALENGTH
will give you the number of bytes. Whereas the LEN
will give you the nuber of characters in a sting and that length is not necessarily the number of bytes.
Note that, another difference between LEN
and DATALENGTH
is that the LEN
excludes trailing blanks while the DATALENGTH
doesn't. Also, be careful with theses functions because it would depend in the collation because Varchar = single byte is not always true as pointed out by @MartinSmith comment below.
Here is a demo for that, you can try it yourself.