如何将阿拉伯字符插入到 SQL 数据库中?

How to insert Arabic characters into SQL database?(如何将阿拉伯字符插入到 SQL 数据库中?)
本文介绍了如何将阿拉伯字符插入到 SQL 数据库中?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何将阿拉伯字符插入到 SQL Server 数据库中?我尝试将阿拉伯语数据插入表中,插入脚本中的阿拉伯语字符作为 '??????' 插入表中.

How can I insert Arabic characters into a SQL Server 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 Server Management Studio直接将数据粘贴到表中,成功准确地插入了阿拉伯字符.

I tried to directly paste the data into the table through SQL Server 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 Server 数据库中插入阿拉伯字符?

How can we insert Arabic characters into SQL Server database?

推荐答案

对于能够存储 unicode 字符的字段,您必须使用类型 nvarchar(或其他类似的类似 ntext, nchar).

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 数据库中?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!

本站部分内容来源互联网,如果有图片或者内容侵犯您的权益请联系我们删除!

相关文档推荐

Execute complex raw SQL query in EF6(在EF6中执行复杂的原始SQL查询)
Hibernate reactive No Vert.x context active in aws rds(AWS RDS中的休眠反应性非Vert.x上下文处于活动状态)
Bulk insert with mysql2 and NodeJs throws 500(使用mysql2和NodeJS的大容量插入抛出500)
Flask + PyMySQL giving error no attribute #39;settimeout#39;(FlASK+PyMySQL给出错误,没有属性#39;setTimeout#39;)
auto_increment column for a group of rows?(一组行的AUTO_INCREMENT列?)
Sort by ID DESC(按ID代码排序)