如何在SQL数据库中插入阿拉伯字符? [英] How to insert arabic characters into sql database?

查看:107
本文介绍了如何在SQL数据库中插入阿拉伯字符?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何将阿拉伯字符插入sql数据库?我试图将阿拉伯数据插入表中,并且插入脚本中的阿拉伯字符在表中作为'??????'插入.

How can I insert arabic characters into sql database? I tried to insert arabic data into a table and the arabic characters in the insert script were inserted as '??????' in the table.

我试图通过sql management studio将数据直接粘贴到表中,并且成功且准确地插入了阿拉伯字符.

I tried to directly paste the data into the table through sql management studio and the arabic characters was successfully and accurately inserted.

我到处寻找解决此问题的方法,一些线程建议将数据类型更改为nvarchar而不是varchar.我也尝试过,但是没有运气.

I looked around for resolutions for this problems and some threads suggested changing the datatype to nvarchar instead of varchar. I tried this as well but without any luck.

如何将阿拉伯字符插入sql数据库?

How can we insert arabic characters into sql database?

推荐答案

要使该字段能够存储unicode字符,您必须使用nvarchar类型(或其他类似的类型,例如ntextnchar)

For the field to be able to store unicode characters, you have to use the type nvarchar (or other similar like ntext, nchar).

要在数据库中插入unicode字符,必须使用nvarchar/SqlDbType.NVarChar这样的参数类型将文本作为unicode发送.

To insert the unicode characters in the database you have to send the text as unicode by using a parameter type like nvarchar / SqlDbType.NVarChar.

(出于完整性考虑:如果要动态创建SQL(与一般建议相反),请在字符串文字前加上N以使其成为unicode.例如:insert into table (name) values (N'Pavan').)

(For completeness: if you are creating SQL dynamically (against common advice), you put an N before a string literal to make it unicode. For example: insert into table (name) values (N'Pavan').)

这篇关于如何在SQL数据库中插入阿拉伯字符?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆