Click here to Skip to main content
15,398,850 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
See more:
problem to insert arabic text as sql variable in sql server 2008 inserts data like this value ???? .How to solve this?

This is my query

insert into tests values(N''+@name)

What I have tried:

I tried to add N' different types in the query.But I can't solve this.
Updated 23-Mar-21 0:42am
Richard MacCutchan 16-May-17 10:13am
There is no problem inserting words in any language: data is data and has no meaning until it is displayed to a human. You just need to ensure that when you select it out of the database you use the correct culture and fonts to display it.
Member 11086281 16-May-17 10:18am
This is my query.

declare @name nvarchar(50);
set @name='محسن';
insert into tests values(N''+@name)

But It saves as ???? in table
ZurdoDev 16-May-17 10:34am
Is the field NVARCHAR?
Member 11086281 17-May-17 0:09am

The N prefix only works on the actual string not a copy of it so:
declare @name nvarchar(50);
set @name = N'محسن';
insert into tests values(@name)
Afzaal Ahmad Zeeshan 16-May-17 10:42am
Mehdi Gholam 16-May-17 11:20am
Maciej Los 16-May-17 14:00pm
It couldn't be so easy... :laugh:
Mehdi Gholam 16-May-17 23:43pm
Member 11086281 17-May-17 0:09am
friends.I am sending @name variable from my c# code to stored procedure.So I can't set value to the variable like above.
How to use N' in that variable?
Mehdi Gholam 17-May-17 0:14am
Then check the collation on your database and change it if needed :
Member 11086281 17-May-17 0:26am
@Mehdi Gholam: Issue solved using the above link .Thank you brother.Thank you all for helping me.
Issue solved using this link [^] suggested by Mehdi Gholam
PIEBALDconsult 17-May-17 0:43am
Please don't answer your own question. Just use Improve question to add detail and context.
Member 11086281 17-May-17 1:20am

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