在SQL Server中,当你处理Unicode字符串常量的时候,你必须在所有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 )

----

例如如下一张表,

CREATE TABLE [dbo].[FeedbackData](

    [username] [nvarchar](16) COLLATE Chinese_PRC_CI_AS NOT NULL,

    [avatar] [nvarchar](32) COLLATE Chinese_PRC_CI_AS NOT NULL,

    [title] [nvarchar](32) COLLATE Chinese_PRC_CI_AS NOT NULL,

    [location] [nvarchar](32) COLLATE Chinese_PRC_CI_AS NOT NULL,

    [datetime] [datetime] NOT NULL,

    [content] [nvarchar](256) COLLATE Chinese_PRC_CI_AS NOT NULL,

    [id] [uniqueidentifier] NOT NULL CONSTRAINT [DF_FeedbackData_uid]  DEFAULT (newid())

) 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'中国的自我认识没有达到社会共识应有的低线,这是当前舆论场上出现一系列重大争议的根源之一。');

评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值