views:

116

answers:

2

Hello everyone,

For SQL Server 2005/2008, after some self-study, I am not sure whether my understanding about how character data type is physically stored is correct. Please help to review and comment. Here is my understanding, please review and feel free to correct me.

  • when using unicode character type (e.g. nvarchar), underlying character are stored in UCS-2 encoding (i.e. character is stored physically in the form of related UCS-2 defined bit sequences for the character). Collation defines comparison and sorting, no codepage in this situation;

  • when using non-unicode character type (e.g. varchar), underlying character are stored physically as bits defined in related code page defined by collation. So in this case, collation defines not only comparison/sorting, but also which codepage (character, bit value represents the character, and using the same bit value to store the character in database physical storage).

thanks in advance, George

+1  A: 

I think you are wright ,see the link for further info http://www.sql-server-helper.com/faq/data-types-p01.aspx

rmdussa
One of my further confusion is -- character are stored physically the same as related bit sequence defined in UCS-2(when using unicode character data type)/codepage(when using non-unicode character data type), no additional level of conversion (between the physical storage and related bit sequence defined in UCS-2/codepage)?
George2
BTW: in the referred document, I did not find how character data type bits are physically stored, i.e. whether the same as UCS-2/codepage defined bit sequence or using some other format (which has an additional level of bit sequence conversion).
George2
+1  A: 

That's seems a quite stupid idea from SQL server since UCS-2 does not allow to store the complete range of Unicode characters. Why didn't they use UTF-8 or UCS-4/UTF-32?

bortzmeyer
Compatible with Windows Mobile? :-)Just joking. Anyway, do you think my understandings in my original question is correct? Feel free to correct any of my mistakes.
George2