问题描述
我使用SQL Server 2005,我尝试存储西里尔字符,但我不能与SQL代码,试图运行这是SQL Server:
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','','');
或者从C#发生同样的问题,但插入/更新列从SQL Server它的工作,是正常存储。
Or from C# is happening the same problem but inserting/updating the column from SQL Server it work and it is store normally.
列的数据类型为 nvarchar
。
推荐答案
您必须在字符串之前添加N前缀。
You have to add N prefix before your string.
当您隐式声明一个字符串变量时, varchar。添加前缀N表示后续字符串为Unicode(nvarchar)。
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','','');
这是一些阅读:
a href =http://databases.aspfaq.com/general/why-do-some-sql-strings-have-an-n-prefix.html =noreferrer> 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
这篇关于SQL代码中的西里尔字符在插入后不正确的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!