godaddy空间的sql server数据库没办法insert中文

原来的代码:

use string007

if exists (select 1
            from  sysobjects
           where  id = object_id('K_V_TEST')
            and   type = 'U')
   drop table K_V_TEST
go

create table K_V_TEST (
    temp                varchar(100)        not null,
   autoid               int                  identity,
   key_                 nvarchar(400)         not null,
   value_               nvarchar(200)         not null,
   constraint PK_K_V_TEST primary key (autoid)
)
go


insert into k_v_test (temp,key_,value_) values('temp','key','value')
insert into k_v_test (temp,key_,value_) values('temp','key','value')
insert into k_v_test (temp,key_,value_) values('temp','年龄','30')
insert into k_v_test (temp,key_,value_) values('temp','性别','')
insert into k_v_test (temp,key_,value_) values('temp','生日','1986-')
insert into k_v_test (temp,key_,value_) values('temp','姓名','张某')
insert into k_v_test (temp,key_,value_) values('temp','手机','18888888888')
go


select * from k_v_test

 

然后执行下看到的中文都会变成'?'。。。。

然后搜了下...

说是在insert的时候,当字符是中文的时候在前面加上'N'就可以了...

果然...

例如:

insert into k_v_test (temp,key_,value_) values('temp',N'年龄','30')

。。。。

现在的代码:

use string007

if exists (select 1
            from  sysobjects
           where  id = object_id('K_V_TEST')
            and   type = 'U')
   drop table K_V_TEST
go

create table K_V_TEST (
    temp                varchar(100)        not null,
   autoid               int                  identity,
   key_                 nvarchar(400)         not null,
   value_               nvarchar(200)         not null,
   constraint PK_K_V_TEST primary key (autoid)
)
go


insert into k_v_test (temp,key_,value_) values('temp','key','value')
insert into k_v_test (temp,key_,value_) values('temp',N'年龄','30')
insert into k_v_test (temp,key_,value_) values('temp',N'性别',N'')
insert into k_v_test (temp,key_,value_) values('temp',N'生日','1986-')
insert into k_v_test (temp,key_,value_) values('temp',N'姓名',N'张某')
insert into k_v_test (temp,key_,value_) values('temp',N'手机','18888888888')
go


select * from k_v_test

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值