0

I have many of my database columns defined as VARCHAR(255) and now would like to input unicode characters (especially the € sign). Inserting data doesn´t show the unicode symbols, but if I update my insert statement to use NVARCHAR paramerts it is working. But why? I didn´t change the column definition from VARCHAR to NVARCHAR.

To support these symbols should I just change all paramerts from VARCHAR to NVARCHAR or should I also update the columns definition to NVARCHAR(255)?

user3740359
  • 395
  • 1
  • 6
  • 16
  • It's because the symbol is unicode and **n**varchar supports it while varchar doesn't. Pretty much the solution here is changing column types to nvarchar and doing the same to all the parameters where you pass values that go into those columns. – MK_ May 04 '18 at 11:36
  • you need to change the type to `nvarchar` to support unicode characters in sql-server – Farshan May 04 '18 at 11:36
  • but you guys have any explanation why it is working with varchar columns and nvarchar paramerters in queries? – user3740359 May 04 '18 at 11:38
  • refer this question https://stackoverflow.com/questions/10965589/unicode-data-type-in-sql – Farshan May 04 '18 at 11:41
  • Possible duplicate of [Unicode Data Type in SQL](https://stackoverflow.com/questions/10965589/unicode-data-type-in-sql) – Farshan May 04 '18 at 11:48
  • 2
    @MK_ That is rather imprecise. The euro symbol also exists in character sets other than unicode (eg ISO-8859-15, windows-1252) – Mark Rotteveel May 04 '18 at 11:53
  • What is your database character set? What does `SELECT * FROM database_name_parameters WHERE parameter LIKE '%CHARACTERSET' return?` – Karthikcbe May 04 '18 at 12:38
  • @Karthikcbe your query gives me an error (after replacing the database name of course). But the collation name is Latin1_General_CI_AS if that helps – user3740359 May 04 '18 at 12:57

2 Answers2

0

Varchar datatype doesn't hold Unicode character. You must convert VARCHAR(255)data type to NVARCHAR(255) inorder to hold Unicode character. Also update the columns definition to NVARCHAR(255)

Sameer
  • 349
  • 4
  • 12
0

use NVARCHAR or change your database character set (export, reinstall with a character set that supports the euro sign like WE8ISO8859P15 or AL32UTF8, and import).

Here's an example of NVARCHAR:

link

Karthikcbe
  • 295
  • 2
  • 12