首页 > 数据库技术 > 详细

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

时间:2016-06-28 14:28:51      阅读:124      评论:0      收藏:0      [点我收藏+]

原来的代码:

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

 

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

原文:http://www.cnblogs.com/love-zf/p/5623278.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!