Pure.Krome
Pure.Krome

Reputation: 87087

How does SQL Server store these Unicode characters into a column that is VARCHAR(MAX) and not NVARCHAR(MAX)

I have some data which I believe is Unicode and seeing what happens when I store it into my database column which is of VARCHAR(MAX) datatype.

enter image description here

And here's the source, from the file which is UTF-8...

looking for that ‘X’ and • 3 large bedrooms with 2 ensuites and • Main bedroom with ensuite & surround with plantation shutters`

and using the Visual Studio debugger:

enter image description here

=> so 2x apostrophes and 2x bullets.

I thought SQL Server can only store Unicode if the column is of type NVARCHAR?

I'm assuming my source data is not Unicode and therefore, I totally suck at all this Unicode/UTF-8 stuff :(

Upvotes: 0

Views: 1410

Answers (1)

bobince
bobince

Reputation: 536765

I thought SQL Server can only store Unicode if the column is of type NVARCHAR?

That's correct. As far as I can guess from your example, it is not storing Unicode. Probably it is storing bytes encoded in Windows code page 1252, which would be the default encoding for a Western install of SQL Server.

Code page 1252 happens to include mappings for characters , and , so those characters can be safely stored. But step outside that limited repertoire and you'll start losing characters.

Upvotes: 2

Related Questions