sqlserver 2005 中文字符查询问题

calmer18 2007-05-04 03:44:51
在本地机器上是好的,把数据导到服务器上出现问题,
查询中文字符总是查不到相应的结果
比如一张news表里包含一条新闻标题为"06年全国中等职业学校毕业生就业率达到95.6%"的数据,用查询语句 select title from news where title like '%95.6%'就能查询到这条数据;而用select title from news where title like '%毕业生%'就查不到这条数据
请问这个问题怎么解决?
...全文
375 7 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
7 条回复
切换为时间正序
请发表友善的回复…
发表回复
calmer18 2007-05-05
  • 打赏
  • 举报
回复
已解决,是数据库排序规则的问题,改变后可以了.
用N''确实也可以查询出来,但是这样程序方面的改动就太多了,所以我选择了改数据库的排序规则. 谢谢各位.
lao_bulls 2007-05-05
  • 打赏
  • 举报
回复
good
CathySun118 2007-05-04
  • 打赏
  • 举报
回复
字符集的问题,用
select title from news where title like N'%毕业生%'
OracleRoob 2007-05-04
  • 打赏
  • 举报
回复
--因为你定义的是nvarchar,需要将串转换为Unicode字符

select title from news where title like N'%毕业生%'
haoanzi 2007-05-04
  • 打赏
  • 举报
回复
SQL在4.1之前对中文的支持一直不是很好,4.1以后有了改善.
在DOS下可以查找到中文,你看到的则是乱码!
其实有过开发经验的,一看就明白.现在送你两个字符转换类(以前项目用的);
根据所以用的数据库的编码方式而用.
public static String iso8859togbk(String in) throws Exception{

String re=null;
try {
re = new String(in.getBytes("iso8859-1"), "gbk");
}
catch (Exception e)
{
throw new Exception("error in convert charset");
}
finally{
return re;
}
}
public static String iso8859togb2312(String in) throws Exception{

String re=null;
try {
re = new String(in.getBytes("iso8859-1"), "gb2312");
}
catch (Exception e)
{
throw new Exception("error in convert charset");
}
finally{
return re;
}

yesyesyes 2007-05-04
  • 打赏
  • 举报
回复
select title from news where title like N'%毕业生%'
calmer18 2007-05-04
  • 打赏
  • 举报
回复
title 字段类型 nvarchar

22,302

社区成员

发帖
与我相关
我的任务
社区描述
MS-SQL Server 疑难问题
社区管理员
  • 疑难问题社区
  • 尘觉
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧