SQL代码中的西里尔字符在插入后不正确 [英] Cyrillic symbols in SQL code are not correctly after insert
问题描述
我使用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
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屋!