Let's just start with an example.
Open SQL Server to create a table:
Create Database testdb
Go
Create Table Test
(
Name1 varchar (10 ),
Name2 nvarchar (10)
)
Go
Insert into test values ('february 5 ', 'february 5, 80 or 90')-success
Insert into test values ('february 5, 80 or 90, ') -- the first field fails to be inserted.
Insert into test values ('february 5 ', 'february 5, 1234, 1234, 80 or 90 1') -- the second field fails to be inserted.
The first field can be inserted into five Chinese Characters
The second field can insert 10 Chinese characters for multiple
Bytes ------------------------------------------------------------------------------------
Insert into test values ('20140901', '20160901') -- Success
Insert into test values ('20140901', '20160901') -- the first field fails to be inserted.
Insert into test values ('20140901', '20160901') -- the second field fails to be inserted.
(Insert letters and ASCII characters. The result is the same)
The first field can insert up to 10 ASCII codes.
The second field can insert 10 ASCII codes for multiple
Bytes ---------------------------------------------------------------------------------------
Insert into test values ('one, Two, Three aaa', 'february 80 or 90, ') -- Success
Insert into test values ('2014, 2, 3 aaaab', '2014, 5, 6, 7, 80 or 90 ') -- the first field fails to be inserted.
Insert into test values ('one, Two, Three aaa', 'August 5, AB ')-success
Insert into test values ('one, Two, Three aaa', 'february, abc') -- insertion of the Second Field failed.
Bytes --------------------------------------------------------------------------------------
Conclusion: up to 10 varchar-type ASCII files and up to 5 Chinese characters can be saved.
Up to 10 ASCII and Chinese characters of the nvarchar type can be saved.
Note: The varchar ASCII character occupies one byte, and the Chinese character occupies two bytes.
The nvarchar type always occupies 2 bytes for one character.
And:
Create Table Test
(
Name1 varchar (10), which occupies 10 bytes of space
Name2 nvarchar (10) -- occupied 20 bytes
)
Verification:
Select * from test
Select name1, Len (name1), name2, Len (name2) from test