its characters are expressed in two bytes, That is, the English character is also represented in two bytes. the length of the nchar and nvarchar is between 1 and 4000. Compared to char and varchar, nchar and nvarchar store up to 4,000 characters, whether in English or Chinese characters, while char and varchar can store up to 8,000 English and 4,000 Chinese characters. It can be seen that the use of nchar,
Description and comparison of database storage types (nchar, char, nvarchar, varchar) for database SQL Server1.char Type:The English (ASCII) characters occupy 1 bytes, a Chinese character occupies 2 bytes, char is convenient to store the fixed length data, the index on the Char field is very efficient, such as the definition of char (10), then regardless of whether the data you stored is 10 bytes, it takes
In SQL Server, when we set character fields, there are often many data types for us to choose from, such as char nchar varchar nvarchar. Which one should we choose? The differences are described one by one.
Char:Fixed Length, non-Unicode character data, length is n Bytes. The value range of n is 1 to 8,000, and the storage size is n Bytes. The synonym for SQL2003 of char is character.
Varchar:Variable Lengt
The varchar (max), nvarchar (max), and varbinary (max) data types are added to SQL Server 2005.
Shard data type (large-value data types) , Marked with the Max specifier. The varchar (max), nvarchar (max), and varbinary (max) data types correspond to SQL Server 2000 and earlier versions of
This article introduces the differences between charncharvarcharnvarchartextntext of character data fields in SQL.
This article introduces the differences between char, nchar, varchar, nvarchar, text, and ntext of character data fields in SQL.
When you enter a certain field, you only need to enter seven numbers for the item number field. When you select a data
The difference between char, varchar, and nvarchar in SQL in the difference between char, varchar, nvarchar char Char is fixed-length, that is, when you enter a character that is less than the number you specify, char (8), the character you enter is less than 8 o'clock, and it will fill the empty value back. When you enter a character that is larger than th
SQL: the primary key of a data table is of the varchar type and does not increase itself. how can I insert a primary key when inserting data? SQL: the primary key of a data table is of the varchar type and does not increase itself. how can I insert a primary key when inserting data?
Reply content:
Q:
What is the difference between varchar and nvarchar in SQL Server? varchar seems to be an English character and a Chinese character both stand in two bytes, while nvarchar is an English character and a Chinese character occupies two bytes. However, this
ProgramWhat is the impact?
A:
Varchar (N)
Variable-length
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
SELECT CONVERT (varchar), CAST (@testFloat as Decimal (38,2))SELECT STR (@testFloat, 38, 2)
Importing from Excel to sql2000, there is a list of "contacts" that have become float types, and I want to convert to nvarchar type, using the following statement
Select convert (nvarchar), convert (int, contact) from employeeGo
Data overflow, no!
Select convert (nvarchar), CONVERT (Decimal (11,0), contact) from employeeGo
Data Conversion Successful!
SELE
according to the actual situation.
Ncahr, nvarchar, ntext. These three kinds of names from the first three more than the previous "N". It represents a character stored in a Unicode data type. We know that characters, the English character only need a byte storage is enough, but the number of Chinese characters, need two bytes of storage, English and Chinese characters at the same time prone to confusion, the Unicode character set is to solve the character set this incompatibility problem, a
do I use these types? If you are sure of the length of the stored data and do not pack in Chinese, you can choose the char type. If you are sure of the stored data length, but may include Chinese, you can choose the nchar type. If you are unsure of the length of the stored data, store only English, the best use of the number varchar If you are unsure of the length of the stored data, it is possible to have Chinese, you can choose the nvarchar type, a
digital, with Char/varchar char,nchar fixed length, fast, occupy space, need to deal withVarchar,nvarchar,text variable length, small space, slow speed, no need to handleNCHAR, NVARCHAR, ntext processing Unicode codes
CHAR (n)
Fixed length
High index Efficiency program use trim to remove extraneous blanks
n must be a numeric value between 1 and 8,000, with a storage size of n bytes
For general string fields in the program, SQL Server has char, varchar, nchar, and nvarchar types. What are the differences between these four types? Here we will make a comparison.
1. Fixed Length or variable length
The so-called fixed length is fixed length. when the length of the data to be saved is insufficient, an English space will be automatically filled behind it to make the length reach the corresp
For general string fields in the program, SQL Server has char, varchar, nchar, and nvarchar types. What are the differences between these four types? Here we will make a comparison.
1. Fixed Length or variable length
The so-called fixed length is fixed length. when the length of the data to be saved is insufficient, an English space will be automatically filled behind it to make the length reach the corresp
For fields with generic string types in your program, there are four types of char, varchar, nchar, and nvarchar in SQL Server, so what's the difference between these four types?
1. Fixed-length or variable-length
The so-called fixed-length is long, when the length of the data to be saved will automatically fill in the back of the English space, so that the length of the corresponding length; there is the
VARCHAR (n)Variable-length, non-Unicode character data with a length of n bytes. n must be a numeric value between 1 and 8,000. Storage size is the actual length of bytes of input data, not n bytes.nvarchar (n)A variable-length Unicode character data that contains 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: me and coffee.The
Differences between char, varchar, text, nchar, nvarchar, and ntext in SQL
1. Char. It is very convenient for Char to store fixed-length data, and the indexing efficiency of char fields is high. For example, if char (10) is defined, no matter whether the data you store reaches 10 bytes, it takes up 10 bytes of space.
2. varchar. Variable-length data is stored,
In SQL, convert the varchar type to the int type and then sort it. If the database ID is set to the orderbyid OF THE varchar type during query
In SQL, convert the varchar type to the int type and then sort it. If the database ID is set to the order by id of the
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.