Arabic langauge not display when i make search by arabic langauge why

Posted by Ahmedsa under Sql Server on 9/6/2014 | Points: 10 | Views : 458 | Status : [Member] | Replies : 3
Hi guys

I have database hr has table Employee this table has field EmployeeName

EmployeeName nvarchar(50)

when i write in query analyzer :

select ^ from Employee where EmployeeName='????'

not give me any result

but when i write

select * from Employee where EmployeeName=N'????'

it give me result

meaning it support arabic

but i have stored procedure not accept arabic and i dont know how to handel it to accept search by EmployeeName

CREATE Procedure sp_EmployeeSelect
@EmployeeName nvarchar(50)
AS
Declare @SQLQuery as nvarchar(2000)
SET @SQLQuery ='SELECT * from Employee Where (1=1)'
If @EmployeeName <>''
Set @SQLQuery = @SQLQuery + ' AND (EmployeeName LIKE ''%'+@EmployeeName +'%'') '
Exec (@SQLQuery)

what is the proplem in this stored procedure and how to solve it

please help me




Responses

Posted by: Kumaran on: 9/6/2014 [Member] Starter | Points: 25

Up
0
Down
Hi,

Same like you i faced problem .
i tried this, now its working fine.

exec sp_EmployeeSelect @EmployeeName=N'??????'

alter Procedure sp_EmployeeSelect--sp_EmployeeSelect '??????'
@EmployeeName nvarchar(50)
AS
Declare @SQLQuery as nvarchar(2000)
SET @SQLQuery ='SELECT * from Employee Where (1=1)'
If @EmployeeName <>''
Set @SQLQuery = @SQLQuery + ' AND (EmployeeName LIKE N''%'+@EmployeeName +'%'') '
Exec (@SQLQuery)

print @EmployeeName

It should work fine.


Ahmedsa, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: vishalneeraj-24503 on: 9/6/2014 [Member] [MVP] Platinum | Points: 25

Up
0
Down
Hi,
Just write N after the LIKE operator as:-
Set @SQLQuery = @SQLQuery + ' AND (EmployeeName LIKE N ''%'+@EmployeeName +'%'')' 


N is an international language character,which supports language other than English.So whenever we want to store other Language in our DB,always keep Datatype as NVarchar and for fetching language write N before any search columns.

Ahmedsa, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Bandi on: 9/8/2014 [Member] [MVP] Platinum | Points: 25

Up
0
Down
Hi Ahmed,

Two things you should remember while searching for any language other than ENGLISH

1. Include N'' in the WHERE search criteria
i.e.
Set @SQLQuery = @SQLQuery + ' AND (EmployeeName LIKE N''%'+@EmployeeName +'%'') '

2. Pre-fix N'' while passing search string for SP input
i.e.
 sp_EmployeeSelect N'?????' 

NOTE: NVARCHAR can store both non-Unicode ( i.e. English ) and Unicode (i.e. Japanese, Korean, Arabic or Hindi etc)


Mark This Response as Answer
--
Chandu
http://www.dotnetfunda.com/images/dnfmvp.gif

Ahmedsa, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response