查询条件包含中文内容的查询失败

feng6060_cn 2006-07-27 10:05:41
当执行以下形式查询的时候,返回空记录,但该表的确存在这样的记录。??
select item1,item2 from table where item1 = '中文'

SQL Server 的排序和字符集是
Latin1-General, case-insensitive, accent-sensitive, kanatype-insensitive, width-insensitive for Unicode Data, SQL Server Sort Order 52 on Code Page 1252 for non-Unicode Data

我试过使用以下几种方式去查询都不能返回正确结果:
1. select item1,item2 from table where item1 = N'中文'
2. select item1,item2 from table where item1 = '中文' collate SQL_Latin1_General_CP1_CI_AS
3. select item1,item2 from table where cast(item1 as nvarchar(50)) = N'中文'
4. select item1,item2 from table where item1 collate SQL_Latin1_General_CP1_CI_AS
= '中文' collate SQL_Latin1_General_CP1_CI_AS

但是用这种方式是可以的,但现实中不能每次都这样做,不知各位有什么好办法?
select item1,item2 from table where item1 = 'ÖÐÎÄ'

...全文
160 3 打赏 收藏 转发到动态 举报
写回复
用AI写文章
3 条回复
切换为时间正序
请发表友善的回复…
发表回复
feng6060_cn 2006-07-28
  • 打赏
  • 举报
回复
问题在SQLServer中没有解决,已在外挂程式中用其它方法实现了。
子陌红尘 2006-07-27
  • 打赏
  • 举报
回复
修改数据库字符集为中文字符集。
turenjie 2006-07-27
  • 打赏
  • 举报
回复
select item1,item2 from table where item1 = '中文' collate Chinese-PRC

22,209

社区成员

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

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