views:

268

answers:

2

The book I am reading says that

SQL Server supports two kinds of character data types—regular and Unicode. Regular data types include CHAR and VARCHAR, and Unicode data types include NCHAR and NVARCHAR. The difference is that regular characters use one byte of storage for each character, while Unicode characters require two bytes per character. With one byte of storage per character, a choice of a regular character type for a column restricts you to only one language in addition to English because only 256 (2^8) different characters can be represented by a single byte.

What I came to know by this is, if I use Varchar then I can use only one language(For ex. Hindi, an Indian Language) along with English.
But When I run this

Create Table NameTable
(
    NameColumn varchar(MAX) COLLATE Indic_General_90_CI_AS_KS
)

It shows me error "Collation 'Indic_General_90_CI_AS_KS' is supported on Unicode data types only and cannot be applied to char, varchar or text data types."

So where have I misunderstood the author?
Thanks

+1  A: 

You can find a list of collations here, along with the encoding type


Certain collations will apply only to 1-byte encodings -- 127 bits are used for normal ASCII and 128 are available for other characters -- hindi probably does not fit in 128 characters so a 1-byte collation does not apply to it.

You will have to use a nvarchar (or other 'n' prefixed character type).

-- edit --

French_CI_AS as a non-english example

One of the things collations enable is language and locale specific ordering of characters. Therefore French != latin.

Another example Arabic_CI_AS

This is a 1-byte encoding with the arabic alphabet.

Hassan Syed
Could u name any 1 byte collation so that I can test it?
Akshay
SQL_Latin1_General_CP1_CI_AS
Hassan Syed
I wanted to know anything other than English actually
Akshay
Added french as a non-english 1-byte collation. Also arabic, to create a contrast.
Hassan Syed
Thanks, I tried ArabicThe Insert Into Was able to insert the Arabic string "مرحبا كيف حالك" But when i open the table in SSMS it shows ?????? Why is it so ?
Akshay
your system default colation is probably latin1. you can only have one 1-byte collation active on a system.
Hassan Syed
A: 

you can use this name = N'مرحبا كيف حالك'