Compare CHAR, NCHAR, VARCHAR, NVARCHAR

Compare CHAR NCHAR VARCHAR NVARCHAR

1. NCHAR, NVARCHAR -> Can Store UniCode Characters
2. CHAR, VARCHAR -> Cannot store all Unicode characters
3. Char, NCHAR -> Fixed Length while storing. If you declare as 100 Characters and store only 2 letters, it uses 100 Characters space in Database
4. VARCHAR, NVARCHAR -> Variable Length. If you declare as 100 characters and store only 2 letters it uses only space for 2 letters
5. NCHAR, NVARCHAR -> will take double the space as CHAR and VARCHAR
6. VARCHAR, NVARCHAR -> Extra 2 Bytes are reserved to store the length of the string
7. Space Usage to store 3 letters and you declare the length as 10
a. CHAR -> 10 Bytes
b. NCHAR -> 20 Bytes (10 * 2)
c. VARCHAR -> 5 Bytes (3 +2)
d. NVARCHAR -> 8 Bytes (3 * 2 + 2)

Advertisements
This entry was posted in SQL and tagged , , , , , , . Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s