Friday, April 20, 2012

SQL - Querying the data using a non-English clause

Seems that the system by default is not set to read or write Unicode Characters even though the declaration of the column is NVARCHAR.


This query returns nothing (Russian clause in this case):
SELECT * FROM MY_TABLE WHERE RUS_COLUMN = 'ФПГ'


Also this INSERT will only store question marks in the DB:
INSERT INTO MY_TABLE (MY_COLUMN) VALUES ('ФПГ')



In order to solve this issue all that has to be done is adding a N character just before the non-English Expression:
SELECT * FROM MY_TABLE WHERE RUS_COLUMN = N'ФПГ'
INSERT INTO MY_TABLE (MY_COLUMN) VALUES (N'ФПГ')


Enjoy!



No comments:

Post a Comment