SQL代码中的西里尔字符在插入后不正确 [英] Cyrillic symbols in SQL code are not correctly after insert

查看:210
本文介绍了SQL代码中的西里尔字符在插入后不正确的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用SQL Server 2005和我尝试存储西里尔字符,但我不能与SQL代码尝试运行这是SQL Server:

  INSERT INTO Assembly VALUES('Македонскипарлиаментброј1','',''); 

或者从C#发生同样的问题,但插入/更新列从SQL Server它的工作和它是正常存储。



列的数据类型为 nvarchar



当你隐式声明一个字符串变量时,它被视为一个字符串变量。 varchar。添加前缀N表示后续字符串为Unicode(nvarchar)。

  INSERT INTO Assembly VALUES(N'Македонскипарлиаментброј1 ','',''); 

以下是一些阅读:



a href =http://databases.aspfaq.com/general/why-do-some-sql-strings-have-an-n-prefix.html> http://databases.aspfaq.com/general/why -do-some-sql-strings-have-an-n-prefix.html



https://msdn.microsoft.com/en-IN/library/ms186939.aspx



前缀的含义是什么N在T-SQL语句中?


I use SQL Server 2005 and I am try to store Cyrillic characters but I can't with SQL code by trying to run this is SQL Server:

INSERT INTO Assembly VALUES('Македонски парлиамент број 1','','');

Or from C# is happening the same problem but inserting/updating the column from SQL Server it work and it is store normally.

The datatype of column is nvarchar.

解决方案

You have to add N prefix before your string.

When you implicitly declare a string variable it is treated as varchar by default. Adding prefix N denotes that the subsequent string is in Unicode (nvarchar).

 INSERT INTO Assembly VALUES(N'Македонски парлиамент број 1','','');

Here is some reading:

http://databases.aspfaq.com/general/why-do-some-sql-strings-have-an-n-prefix.html

https://msdn.microsoft.com/en-IN/library/ms186939.aspx

What is the meaning of the prefix N in T-SQL statements?

这篇关于SQL代码中的西里尔字符在插入后不正确的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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