Strings Are Hard

Kenneth Fisher on varchar versus nvarchar:

In any study of Data Types in SQL Server you are going to have to look at the various string data types. One important component is the difference between nChar vs Char and nVarChar vs VarChar. Most people reading this are probably thinking “Well that’s ridiculously easy.” If you are one of them then I want you to read these two facts about these data types.

Char and VarCharnChar and nVarChar
StoresASCIIUNICODE
SizeAlways one byte per character.Always two bytes per character.

One of these is incorrect. Do you know which one?

The correct answer is “both are wrong.”  Then you get into debates about what a “character” is, how certain languages (like Hebrew and Arabic) have layers of modifiers which modify semantic context, etc. etc.  Strings are probably even harder than dates.

Related Posts

Thoughts on Certification

Eugene Meidinger is certifiable: This being a complex topic, I thought I’d lay out the various factors to give a more comprehensive answer than you can easily fit in a tweet. So the first two questions we need to answer are “Why do certs exist?” and “Why do people take them?”. Without these, we can’t […]

Read More

Disable Lightweight Pooling

Randolph West explains why enabling lightweight pooling in SQL Server is almost always a bad idea: When can I enable lightweight pooling then?Don’t. But if you must, these are the conditions under which Microsoft suggests it may be useful:– Large multi-processor servers are in use.– All servers are running at or near maximum capacity.– A lot […]

Read More

Categories

December 2015
MTWTFSS
« Nov Jan »
 123456
78910111213
14151617181920
21222324252627
28293031