I have a problem in SQL Server 2000 when searching for a term in farsi
-
14-10-2019 - |
Question
I have a problem in SQL Server 2000 with farsi search.
I have a table with nvarchar
fields with unicode (farsi) values and need to search content of that with unicode (farsi) text.
I am using
select * from table1
where fieldname like '%[farsi word]%'
My farsi word is exist but return 0 row.
What can I do?
thanks all.
Solution
If you're using NVARCHAR
fields, you should also use Unicode when searching! You do this by prepending a N
before your search term:
select * from table1
where fieldname like N'%[farsi word]%'
Also: be aware the if your search term begins with a %
wildcard, you've basically disabled all use of any indices there might be to speed up your search. Using LIKE %...%
for searching will always result in a pretty slow table scan....
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow