1
    Declare @Topic nvarchar(2000) ='.کثیر الانتخاب جواب میں سے صحیح جواب منتخب کیجئے'

    SELECT  TextbookTopicId,Title FROM TextbookTopic tt WHERE tt.Title =@Topic

I declared a variable and use in where clause but its not working. but if i use 'N' and remove variable from where clause and use text directly in where clause then it works fine


SELECT  TextbookTopicId,Title FROM TextbookTopic tt WHERE tt.Title =N'.کثیر الانتخاب جواب میں سے صحیح جواب منتخب کیجئے'
Tayyeb
  • 127
  • 7
  • Which DBMS product are you using? "SQL" is just a query language used by all relational databases, not the name of a specific database product and full text search is vendor specific. Please add a [tag](https://stackoverflow.com/help/tagging) for the database product you are using. [Why should I tag my DBMS](https://meta.stackoverflow.com/questions/388759/) –  Dec 08 '20 at 10:57

1 Answers1

1

You need the N before the constant:

Declare @Topic nvarchar(2000) = N'.کثیر الانتخاب جواب میں سے صحیح جواب منتخب کیجئے';

Otherwise, the value is a varchar() constant that gets converted to nvarchar().

Gordon Linoff
  • 1,242,037
  • 58
  • 646
  • 786
  • i want to pass a dynamic parameter , how can i use 'N' with dynamic parameter – Tayyeb Dec 08 '20 at 12:15
  • @Tayyeb . . . Just use an `nvarchar()` -- and then be sure that you set it properly. The issue in your code is how you are *setting* the value, not how you are passing it. – Gordon Linoff Dec 08 '20 at 14:04