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 ...
随机推荐
- zz[C++]合理的设计和使用消息队列
http://www.cnblogs.com/egmkang/archive/2012/11/17/2763295.html 生产者消费者问题,是永远的经典. 单纯让多个线程去竞争,占有资源然后处理, ...
- mysql数据库数据恢复方案概括总结
方案一:(传统方案) 备份+binlog日志增量: 方案二:(针对update.delete语句忘加where的情况) Binlog日志文件中保存有错误操作之前和之后的两组数据,将错误操作之前的数据修 ...
- AngularJS中serivce,factory,provider的区别
一.service引导 刚开始学习Angular的时候,经常被误解和被初学者问到的组件是 service(), factory(), 和 provide()这几个方法之间的差别.This is whe ...
- 切记ajax中要带上AntiForgeryToken防止CSRF攻击
在程序项目中经常看到ajax post数据到服务器没有加上防伪标记,导致CSRF被攻击,下面小编通过本篇文章给大家介绍ajax中要带上AntiForgeryToken防止CSRF攻击,感兴趣的朋友一起 ...
- Vue.js实现拼图游戏
Vue.js实现拼图游戏 之前写过一篇<基于Vue.js的表格分页组件>的文章,主要介绍了Vue组件的编写方法,有兴趣的可以访问这里进行阅读:http://www.cnblogs.com/ ...
- 【写一个自己的js库】 5.添加修改样式的方法
1.根据id或class或tag修改样式,样式名是-连接格式的. function setStyleById(elem, styles){ if(!(elem = $(elem)) return fa ...
- GNU所有软件下载,其中最有意思的是octave
http://ftp.gnu.org/gnu/ 最有意思的是octave:https://www.gnu.org/software/octave/http://ftp.gnu.org/gnu/octa ...
- ASP.NET MVC:多模板支持
原文 http://www.cnblogs.com/happyframework/p/3224278.html 背景 准备写个博客练习一下WEB编程,有一个需求就是多模板支持,类似博客园的自定义模板一 ...
- C语言的本质(14)——不完全类型和复杂声明
ISO 将 C 的类型分为三个不同的集合: 函数.对象和不完全类型三大类.函数类型很明显:对象类型包含其他一切,除非不知道对象的大小.该标准使用术语"对象类型"指定指派的对象必须具 ...
- linux之SQL语句简明教程---表格连接
现在我们介绍连接 (Join) 的概念.要了解连接,我们需要用到许多我们之前已介绍过的指令.我们先假设我们有以下的两个表格, Store_Information 表格 Store_Name Sales ...