0

How to retrieve data from a SQL Server stored procedure by using hindi parameter?

I have tried like this:

declare @A nvarchar (max), @b nvarchar(max), @c nvarchar(max)
set @b = N'नईम '
print @b

But used @b as a parameter then it will work :

declare @A nvarchar (max),@b nvarchar(max),@c nvarchar(max)
 set @b = 'नईम '
 print @b

then no results found

Pass hindi parameter like in sp :

[Up_searchbyperameter] 35,62,0,'नाम'

kindly give me any solution

In stored procedure, there is one parameter @datavalue which contain Hindi word, but by using stored procedure, I am unable to retrieve hindi data

Please help...

marc_s
  • 732,580
  • 175
  • 1,330
  • 1,459
Nayeem Mansoori
  • 821
  • 1
  • 15
  • 41

1 Answers1

2

I'm not sure I understand exactly, but it looks like one of the problems is that you're using varchar literals when you need to use nvarchar literals.

You can see the problem if you run this:

SELECT 'नाम' "A",
    N'नाम' "B",
    cast('नाम' as nvarchar(10)) "C"

You should get these results:

A   B   C
--- --- ---
??? नाम ???

See how column A and C are unknown characters? That's because they were entered as varchar literals and not nvarchar literals. Hindi characters aren't valid in varchar fields, so they get converted to question marks.

So, if I understand what you're asking, I think you need to use:

declare @A nvarchar (max), @b nvarchar(max), @c nvarchar(max)
set @b = N'नईम'
exec [Up_searchbyperameter] 35,62,0,@b
Bacon Bits
  • 30,782
  • 5
  • 59
  • 66
  • [Up_searchbyperameter] 35,62,0,'नाम' i m pass likes this – Nayeem Mansoori Apr 17 '15 at 13:50
  • @NayeemMansoori Are you saying that running `exec [Up_searchbyperameter] 35,62,0,'नाम'` works, or that that's what you're trying and it does not work? – Bacon Bits Apr 17 '15 at 13:55
  • 1
    @NayeemMansoori Is the fourth parameter of `[Up_searchbyperameter]` defined in the stored procedure definition as a varchar or an nvarchar? It needs to be an nvarchar there, too, or you won't be able to use Hindi characters in the parameter. – Bacon Bits Apr 17 '15 at 14:00