Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Check alphabets in SQL Server

I am developing a website in asp.net (C#) having two languages "English" and "Persian". I have a search field in front end and I want to pick the English name when I do search in English and to pick the Persian name when I do search in Persian.

I have record in table in the following format:

===========================
   Name     |Persian Name|
===========================
Faridullah  |    فریدالله   |

I have a search field in front end. So I want to pick "Name" when I enter English alphabet and when the language is changed means when I enter Persian alphabet Persian name should be picked. so how could I do that in a query.

like image 486
Loyal Avatar asked Oct 09 '15 07:10

Loyal


People also ask

How do I view the alphabet in SQL?

To check if string contains letters uses the operator LIKE with the following regular expression '[A-Za-z]%'.

How do you find alphanumeric values in SQL?

You can use these SQL data types to store alphanumeric data: CHAR and NCHAR data types store fixed-length character literals. VARCHAR2 and NVARCHAR2 data types store variable-length character literals. NCHAR and NVARCHAR2 data types store Unicode character data only.

How check string is alphanumeric in SQL?

How do you check if a value is alphanumeric in SQL? Answer: To test a string for alphanumeric characters, you could use a combination of the LENGTH function, TRIM function, and TRANSLATE function built into Oracle. The string value that you are testing. This function will return a null value if string1 is alphanumeric.


1 Answers

You can simple use OR in your WHERE clause in following:

SELECT *
FROM Tbl
WHERE @name = Name OR @name = [Persian Name];

Or slightly shortened

SELECT *
FROM Tbl
WHERE @name IN (Name, [Persian Name]);
like image 101
Stanislovas Kalašnikovas Avatar answered Sep 21 '22 22:09

Stanislovas Kalašnikovas