1

Does anyone know of a simple chart or list that would show all acceptable varchar characters? I cannot seem to find this in my googling.

jackncoke
  • 2,000
  • 6
  • 25
  • 66
  • 1
    The characters that can be represented in varchar depend on the code page used. My answer here has a script to get them for all collation families http://stackoverflow.com/a/5206519/73226 – Martin Smith Aug 09 '13 at 19:52
  • 1
    You are probably using Win1252 http://en.wikipedia.org/wiki/Windows-1252 – paparazzo Aug 10 '13 at 10:27

1 Answers1

1

What codepage? Collation? Varchar stores characters assuming a specific codepage. Only the lower 127 characters (the ASCII subset) is standard. Higher characters vary by codepage.

The default codepage used matches the collation of the column, whose defaults are inherited from the table,database,server. All of the defaults can be overriden.

In sort, there IS no "simple chart". You'll have to check the character chart for the specific codepage, eg. using the "Character Map" utility in Windows.

It's far, far better to use Unicode and nvarchar when storing to the database. If you store text data from the wrong codepage you can easily end up with mangled and unrecoverable data. The only way to ensure the correct codepage is used, is to enforce it all the way from the client (ie the desktop app) to the application server, down to the database.

Even if your client/application server uses Unicode, a difference in the locale between the server and the database can result in faulty codepage conversions and mangled data.

On the other hand, when you use Unicode no conversions are needed or made.

Panagiotis Kanavos
  • 120,703
  • 13
  • 188
  • 236