当前位置:   article > 正文

在SQL Server中,当你处理Unicode字符串常量的时候,你必须在所有Unicode字符串前添加N前缀_sqlserver unicode处理 参数 n

sqlserver unicode处理 参数 n

You must precede all Unicode strings with a prefix N when you deal with Unicode string constants in SQL Server

When dealing with Unicode string constants in SQL Server you must precede all Unicode strings with a capital letter N, as documented in the SQL Server Books Online topic "Using Unicode Data". The "N" prefix stands for National Language in the SQL-92 standard, and must be uppercase. If you do not prefix a Unicode string constant with N, SQL Server will convert it to the non-Unicode code page of the current database before it uses the string. (摘自msdn,http://support.microsoft.com/kb/239530/en-us )

----

例如如下一张表,

  1. CREATE TABLE [dbo].[FeedbackData](
  2. [username] [nvarchar](16) COLLATE Chinese_PRC_CI_AS NOT NULL,
  3. [avatar] [nvarchar](32) COLLATE Chinese_PRC_CI_AS NOT NULL,
  4. [title] [nvarchar](32) COLLATE Chinese_PRC_CI_AS NOT NULL,
  5. [location] [nvarchar](32) COLLATE Chinese_PRC_CI_AS NOT NULL,
  6. [datetime] [datetime] NOT NULL,
  7. [content] [nvarchar](256) COLLATE Chinese_PRC_CI_AS NOT NULL,
  8. [id] [uniqueidentifier] NOT NULL CONSTRAINT [DF_FeedbackData_uid] DEFAULT (newid())
  9. ) ON [PRIMARY]


想要插入数据,则需要这样子写SQL:

insert into FeedbackData ( username, avatar, title, location, datetime, content)

values( N'张大千', N'3', N'界面问题很大', N'浙江省', '2013-01-02 00:02:00', N'中国的自我认识没有达到社会共识应有的低线,这是当前舆论场上出现一系列重大争议的根源之一。');

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/AllinToyou/article/detail/525681
推荐阅读
相关标签
  

闽ICP备14008679号