September 5, 2014 at 11:50 pm
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
September 6, 2014 at 11:01 am
In the stored procedure you generate the string SELECT * from Employee where EmployeeName LIKE '%????%'
What you need is the stringSELECT * from Employee where EmployeeName LIKE N'%????%'
So you need to alter the alter the stored procedure so that the last addition to the code string to be
Set @sqlquery = @sqlquery + ' AND (EmployeeName LIKE N''%'+@EmployeeName +'%'') '
I think the problem is that the string you generate tries to match with 8-bit encoding of the Arabic text (presumably using an appropriate code page) but you actually need to match the 16-bit unicode encoding.
I know that adding the missing "N" will make your stored procedure work even if the mechanism behind the failure to match is slightly different from that.
Tom
Viewing 2 posts - 1 through 1 (of 1 total)
You must be logged in to reply to this topic. Login to reply