Click here to Skip to main content
15,914,222 members
Please Sign up or sign in to vote.
4.50/5 (2 votes)
Hai,
 i am trying to get the Arabic matched values from the DataBase using  stored procedure in sqlserver 2008..
But it didn't returns the matched values.. why..

My Table Design is like

SQL
CREATE TABLE #test1
(
col1 nVARCHAR(100)  ,
col2 nVARCHAR(100)  ,
col3 NVARCHAR(100)
)

INSERT INTO #test1 VALUES(N'لا أتكلم العربية',N'لا أتكلم العربية',N'لا أتكلم العربية')

INSERT INTO #test1 VALUES( ' fdfdf', 'dfdfdf', '45dfdf')

SELECT * FROM #test1

it showing the result like below well...

col1	col2	col3
لا أتكلم العربية	لا أتكلم العربية	لا أتكلم العربية
 fdfdf	dfdfdf	45dfdf



The given query giving the exact results while i am searching for the Arabic words..
SQL
declare @ColVal nvarchar(100)
 set @ColVal=   N'لا أتكلم العربية'
print @ColVal
select * from #test1 where col2 like @ColVal



But when i trying to retrieve the same data using the Stored Procedure it doesn't showing the Matched records any more even they exist in table..

My stored Procedure is


SQL
create proc Sp_TestArabic1 (@colValue nvarchar(100))
as
declare @ColVal nvarchar(100)
begin
set @ColVal=  'N'+@colValue
print @ColVal
select * from #test1 where col2 like @ColVal
end


SQL
exec Sp_TestArabic1 'لا أتكلم العربية'


Doesn't give any results , I tried with debugging the Stored porcedure, all the columns passes the values well but it doesn't returns the Correct results..


please provide exact solution to search the Arabic words based on the Condition...

Thank you..
Posted
Comments
Bernhard Hiller 4-Jun-12 2:54am    
Are you sure you need that "N" in set @ColVal='N'+@colValue?
I do not know that with stored procedures, I know that when doing SQL queries directly that N is needed, but with C# and parameterized queries it is not.
V G S Naidu A 4-Jun-12 3:19am    
me to Don't no exactly how to pass the arabic values to stored procedure,, that what i am asking for the better solution...

1 solution

While executing the procedure from C# code, you need to pass parameter with 'N' prefix.
like this
exec Sp_TestArabic1 N'لا أتكلم العربية'

Make sure the parameter value should be in arabic, not N'????'
 
Share this answer
 
Comments
V G S Naidu A 6-Jun-12 0:04am    
i passed like this so... it doesn't work but when the i gave the N in query it is acceptable.. like query="Select * from table1 where EmpName like N"+@parameter1;

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900