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 ...
随机推荐
- Hello又大了一岁
时间就这样子过了一年一年一年一年一年...一年一年一年......... 以往每年的生日,都习惯安静的猫在一个地方.时间流逝,更像是一种默默的悼念. 也许从28岁开始,我得习惯用逗比的心态欢迎.长大的 ...
- 整理:GET与POST的区别
1.根据HTTP规范,GET用于信息获取,而且应该是安全的和幂等的. (1).所谓安全的意味着该操作用于获取信息而非修改信息.换句话说,GET 请求一般不应产生副作用.就是说,它仅仅是获取资源信息,就 ...
- Python之路第七天,基础(9)-面向对象(上)
面向对象的编程思想 回想 我们所学过的编程方法: 面向过程:根据业务逻辑从上到下写堆叠代码. 函数式编程:将重复的代码封装到函数中,只需要写一遍,之后仅调用函数即可. 面向过程编程最易被初学者接受,其 ...
- ORA-01653:表无法通过64(在表空间USERS中)扩展
问题描述:oracle插入数据时显示ORA-01653 表无法通过64(在表空间USERS中)扩展 原因: oracle 表空间满了,需要扩展 截图: 解决方法: 1.首先查下表空间 select ...
- eclipse 常用的一些设置
1.行长度设置 http://blog.csdn.net/janronehoo/article/details/10047937 2.字体 windows -> preference -> ...
- 一步一步学python(六) - 抽象
1.string转数字 import locale locale . atoi( str ) 2.创建函数 函数是可以调用(可能包含参数),执行某种行为并返回一个值 >>>impo ...
- Linux基本命令(开发常用的、电脑常用的)
一.开发常用的 ###转自:http://www.weixuehao.com/archives/25#usergroup 转自:http://blog.csdn.net/ljianhui/articl ...
- 电子科大POJ "整数的千位分隔"
整数的千位分隔 Time Limit: 3000/1000MS (Java/Others) Memory Limit: 65535/65535KB (Java/Others) C-source ...
- poj 3761 Bubble Sort_快速幂
题意:问你冒泡排序第i次排序,一共排了多少次 套公式K!((K + 1) ^ (N - K) - K ^ (N - K)) #include <iostream> #include< ...
- C#字符串处理 及字符串格式化
本文来自:http://www.cnblogs.com/xuerongli/archive/2013/03/23/2976669.html string字符串是char的集合,而char是Unicod ...