Cannot resolve the collation conflict between "SQL_Latin1_General_CP1_CI_AS" and "Chinese_PRC_CI_AS" in the equal to operation.
Scenario :
这个问题是我的存储过程中用到临时表时发生的。
应该是sql server 服务器的排序规则 (SQL_Latin1_General_CP1_CI_AS )
与数据库的排序规则(Chinese_PRC_CI_AS)不同导致的吧。
Solution :
在创建临时表时在相应的字段定义加上Collate Database_Default ,问题就解决了。
如下:
USE [JointFrame2]
GO
/****** Object: StoredProcedure [dbo].[Proc_enterprise_unified_sam] Script Date: 2016/10/28 10:23:00 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
--此存储过程将名称相似度大于80%的数据的主子记录标识设置为初始值
ALTER PROCEDURE [dbo].[Proc_enterprise_unified_sam]
AS
--=============================================================================== BEGIN
DECLARE
@id VARCHAR(40), --记录ID
@psname VARCHAR(220), ---污染源名称
@region_code VARCHAR(20), --污染源区域编码
@i BIGINT --记录执行
set @i = 0
--创建临时表,用于存放相似度大于80%的数据
create table #temp1(
--加上COLLATE datebase_default NULL是为了避免此错误
id varchar(50) COLLATE database_default NULL
)
-- 定义游标.
DECLARE mycursor CURSOR FOR
--查找出未统一的污染源信息的区域编码和污染源名称
select id,region_code,psname from t_unified_enterprise_info where main_or_child = 1 and system_source != 0
--打开游标
OPEN mycursor
--填充数据
FETCH NEXT FROM mycursor INTO @id,@region_code,@psname
--判断游标的状态
-- 0 fetch语句成功
---1 fetch语句失败或此行不在结果集中
---2 被提取的行不存在
WHILE @@FETCH_STATUS = 0
BEGIN
set @i = @i + 1
print @i insert into #temp1
select id from (
select * from (
SELECT id,psname,dbo.FN_Resemble(@psname,psname) as a1,dbo.FN_Resemble(psname,@psname) as b1
FROM [dbo].[t_unified_enterprise_info] where region_code =@region_code)u where u.a1>=0.6) uu
where (uu.a1+uu.b1)/2>0.8 --如果相似度大于80%的数据在临时表中的条数大于1,则将他们全部置为初始值 if((select count(id) from #temp1)>1)
BEGIN
update t_unified_enterprise_info set main_or_child = 0,parentid = NULL,unique_code = NULL where system_source != 0 and id in (select id from #temp1)
END
delete from #temp1
--用游标去取下一行记录
FETCH NEXT FROM mycursor INTO @id,@region_code,@psname
END
--关闭游标
CLOSE mycursor
--删除游标
DEALLOCATE mycursor
END --exec [Proc_enterprise_unified_sam]
比较相似度的函数:
Cannot resolve the collation conflict between "SQL_Latin1_General_CP1_CI_AS" and "Chinese_PRC_CI_AS" in the equal to operation.的更多相关文章
- Cannot resolve the collation conflict between "SQL_Latin1_General_CP1_CI_AS" and "Latin1_General_100_CI_AS" in the equal to operation.
ErrorMessage Cannot resolve the collation conflict between "SQL_Latin1_General_CP1_CI_AS" ...
- Cannot resolve the collation conflict between "SQL_Latin1_General_CP1_CI_AS" and "Chinese_PRC_CI_AI" in the equal to operation.
Executed as user: NT AUTHORITY\SYSTEM. Cannot resolve the collation conflict between "Chinese_P ...
- sql server 小技巧(6) Cannot resolve the collation conflict between "Latin1_General_CI_AI" and "Chinese_PRC_CI_AS" in the equal to operation
今天查询二个db,出现这个错误,二种方法,一种是把db里的collation改成一样的:如果不方便可以直接在sql语句后面转一下: select * from table where crm_mscr ...
- sql server Cannot resolve the collation conflict between "Chinese_PRC_BIN" and "Chinese_PRC_CI_AS" in the equal to operation
今天查询二个db,出现这个错误,二种方法,一种是把db里的collation改成一样的:如果不方便可以直接在sql语句后面转一下: select * from table where crm_mscr ...
- conflict between "Chinese_PRC_CI_AI" and "Chinese_PRC_CI_AS" in the equal to operation
在SQL SERVICE做关联查询的时候遇到了"conflict between "Chinese_PRC_CI_AI" and "Chinese_PRC_CI ...
- SQL Server, Cannot resolve the collation conflict
今天遇到一个较为头痛的问题: Cannot resolve the collation conflict between "Chinese_PRC_90_CI_AS" and &q ...
- 解决SQL Server的cannot resolve the collation conflict问题
当没有牵涉到两个不同的数据库时,出现以上错误. Cannot resolve the collation conflict between "Chinese_PRC_CI_AS" ...
- Cannot resolve the collation conflict between "Chinese_PRC_CI_AS" and "SQL_L及由于排序规则不同导致查询结果为空的问题
报错:Cannot resolve the collation conflict between "Chinese_PRC_CI_AS" and "SQL_L 出错原因: ...
- Cannot resolve collation conflict between "Chinese_Taiwan_Stroke_CI_AS" and "Chinese_PRC_CI_AS" in UNION ALL operator occurring in SELECT statement column 1.
Cannot resolve collation conflict between . 解决方案: COLLATE Chinese_PRC_CI_AS 例子: SELECT A.Name FROM A ...
随机推荐
- cocos2d.js
1.节点是Cocos2d最基础的东西 2.坐标与普通数学坐标一致 3.children属性表示节点的孩子,父节点位置变化,它包含的子节点也会跟着变化,以整体的形势移动 4.层(layer), 新建层: ...
- ~/microwindows-0.89pre8/src/bin$ ./nano-X error:Cannot bind to named socket
GUI:microwindows-0.89pre8+nona-X you are successful compiling, run nano-X,below is information: ~/mi ...
- Java Thread 总结
目 录 线程的概述(Introduction) 线程的定义(Defining) 1) 继承java.lang.Thread类 2) 实现java.lang.Runnable接口 线程的启动(St ...
- ZigBee 技术简介
Zigbee是IEEE 802.15.4协议的代名词.根据这个协议规定的技术是一种短距离.低功耗的无线通信技术.这一名称来源于蜜蜂的八字舞,由于蜜蜂(bee)是靠飞翔和“嗡嗡”(zig)地抖动翅 ...
- Unix/Linux环境C编程入门教程(34) 编程管理系统中的用户
1.用户管理相关函数介绍 geteuid(取得有效的用户识别码) 相关函数 getuid,setreuid,setuid 表头文件 #include<unistd.h> #include& ...
- OpenSuSE zypper repo及Desktop媒体播放器设置 for OpenSuSE12.
1.禁用官方源和DVD光盘源,启用中国大陆源 使用DVD光盘安装好openSUSE 12.2之后,软件安装源中默认存在一个名称为”openSUSE-12.2-1.6″的软件源,这个源的URL实际上是指 ...
- javascript第十六课:动态注册事件
直接给dom元素添加动态事件,如: document.getelementbyid('#id').onclick=function(){ 方法体! };
- PHP出现Notice: unserialize() [function.unserialize]: Error at offset问题的解决方案
有两个原因(据我所知)会导致这个问题: (1) 字符串本身的问题 (2)字符编码的问题. 你unserialize的字符串的编码和文件本身的编码不一致.将文件编码改成和字符串一样的编码.这种问题比较隐 ...
- ffmpeg+SDl+ 播放器 -01
最近因公司项目需要,打算自己在LINUX平台整一个播放器,来学习和研究音频编解码. 项目需求: 支持下列格式文件播放. 1> WMA 硬件解码,但需要软件分析ASF格式,提取Payload数据 ...
- Lucene 4.4 依据Int类型字段删除索引
1.方法一,通过Term删除 Term构造中没有.Int类型须要转换成Lucene自带的类BytesRef . /** * 依据商品ID删除索引文件 * @param id */ public voi ...