关于sqlserver里的字符集“SQL_Latin1_General_CP1_CI_AS”、“Chinese_PRC_CI_AS” 报错的解决方法
问题1:
Cannot resolve the collation conflict between "Chinese_PRC_CI_AS" and "SQL_Latin1_General_CP1_CI_AS" in the equal to operation.
SQL查询出现这样的问题
或者
Cannot resolve the collation conflict between "SQL_Latin1_General_CP1_CI_AS" and "Chinese_PRC_CI_AS" in the equal to operation.
原因是你在建库的时候使用的是系统默认字符集 "SQL_Latin1_General_CP1_CI_AS",后边你更改过,所以在查询的时候报错。
解决方案
1,首先确定你目前的字符集是什么
数据库右键>属性>选项
![](http://upload-images.jianshu.io/upload_images/20058134-af261febb309a896.png?imageMogr2/auto-orient/strip|imageView2/2/w/712/format/webp)
2,找到有问题的表
表右键>设计
字符集的问题都是varchar或者nvarchar类型的数据字符集与目标查询的字符集不相同
![](http://upload-images.jianshu.io/upload_images/20058134-45ce709660641f64.png?imageMogr2/auto-orient/strip|imageView2/2/w/1048/format/webp)
修改为
![](http://upload-images.jianshu.io/upload_images/20058134-bd4b080e3944c42e.png?imageMogr2/auto-orient/strip|imageView2/2/w/904/format/webp)
3,也可以使用sql语句
ALTER TABLE 表名 ALTER COLUMN 字段 VARCHAR(100) COLLATE Chinese_PRC_CI_AS
4,整体修改数据库的字符集
ALTER DATABASE testDB COLLATE Chinese_PRC_CI_AS; GO
但是这样会有一个问题,你修改了数据库字符集之后,你之前已建的表的字段的字符集还是之前的,所以需要你查找后一一去改。