The difference and use method of varchar and nvarchar in SQL _mssql

Source: Internet
Author: User
Tags numeric value
Ask:
What is the difference between varchar and nvarchar in SQL Server, varchar seems to be an English and a Chinese character is standing two bytes, while nvarchar is an English account of a byte, Chinese characters accounted for two bytes. But what effect does this have on the ASP program?
For:
VARCHAR (n)
A variable length of n bytes and non-Unicode character data. n must be a numeric value between 1 and 8,000. The actual length of the byte that the storage size is the input data, not the N bytes.

nvarchar (n)
Variable-length Unicode character data containing n characters. The value of n must be between 1 and 4,000. The storage size of bytes is twice times the number of characters entered.

Two fields have field values: coffee and I
The varchar field occupies 2x2+6=10 bytes of storage, while the nvarchar field occupies 8x2=16 bytes of storage space.

If the field value is only English can choose varchar, while the field value exists more double-byte (Chinese, Korean, etc.) characters with nvarchar

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.