Type in SQL Server varchar and nvarchar types What is the difference?

Type in SQL Server varchar and nvarchar types What is the difference?

Answer was:

varchar (n)
variable length of n bytes and non-Unicode character data. n must be a number between 1 and 8,000 nm. Storage size is the actual length of the input data byte, but not n bytes.
nvarchar (n)
containing n characters in a variable-length Unicode character data. The value of n must be between 1 and 4,000. Bytes of storage size is twice the number of the character input.

There are two fields are field values: I coffee and
then varchar field representing 2 × 2 + 6 = 10 bytes of storage space, and nvarchar field representing 8 × 2 = 16 bytes of storage space.

The field values ​​in English only Alternatively varchar, while the presence of more-byte field value (Chinese, Korean, etc.) characters nvarchar

The above is a summary presentation, by the above description, you can know.

varchar (4) can be entered four word lines, two characters can be entered

nvarchar (4) can enter four characters, can lose four letters, but up to four

The second was:

If you can not distinguish between varchar and nvarchar, it can be understood:
Q:
SQL Server in varchar and Nvarchar What is the difference ah, varchar like an English and a Chinese character stood two bytes, and is an English Nvarchar one byte, two bytes characters. But this have any effect on the asp program?

A:
VARCHAR (n)
of length n bytes of variable-length and non-Unicode character data. n must be a number between 1 and 8,000 nm. Storage size is the actual length of the input data byte, but not n bytes.

nvarchar (n)
containing n characters in a variable-length Unicode character data. The value of n must be between 1 and 4,000. Bytes of storage size is twice the number of the character input.

There are two fields are field values: I coffee and
then varchar field representing 2 × 2 + 6 = 10 bytes of storage space, and nvarchar field representing 8 × 2 = 16 bytes of storage space.
The field values in English only Alternatively varchar, while the presence of more-byte field value (Chinese, Korean, etc.) characters nvarchar.

Released six original articles · won praise 0 · Views 1211

Guess you like

Origin blog.csdn.net/qq_33846125/article/details/90204874