Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

SQL query in C# not support Hebrew

Tags:

c#

sql

I have a problem when I do a SQL query with Hebrew:

"select ProductName From Products WHERE TypeOfProduct ='מעבד'"

I have TypeOfProduct set, that's have the value 'מעבד', but the query returns null.

If I replace the hebrew word in something like numbers or english words, everything goes fine.

How do I use hebrew in SQL queries?

like image 563
ShmuelCohen Avatar asked Feb 28 '13 18:02

ShmuelCohen


People also ask

What is SQL query example?

An SQL SELECT statement retrieves records from a database table according to clauses (for example, FROM and WHERE ) that specify criteria. The syntax is: SELECT column1, column2 FROM table1, table2 WHERE column2='value';

Can we use database in C?

This IDE is specially designed for C and C++ and easy to use. SQLAPI++ is a C++ library (basically a set of header files) for accessing multiple SQL databases (Oracle, SQL Server, DB2, Sybase, Informix, InterBase, SQLBase, MySQL, PostgreSQL, SQLite, SQL Anywhere and ODBC).

What are the 3 types of SQL?

The lists in the following sections provide a functional summary of SQL statements and are divided into these categories: Data Definition Language (DDL) Statements. Data Manipulation Language (DML) Statements.


1 Answers

You should use Unicode by using the "N" prefix before the string i.e. N'מעבד' in your where clause...

    select ProductName From Products WHERE TypeOfProduct = N'מעבד'

You also need to make sure that your column is of type nvarchar and not varchar.

If you cannot use nvarchar and Unicode string you will have to change the collation of your database from LATIN to HEBREW.

like image 91
Mortalus Avatar answered Oct 20 '22 00:10

Mortalus