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.的更多相关文章

  1. 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" ...

  2. 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 ...

  3. 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 ...

  4. 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 ...

  5. 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 ...

  6. SQL Server, Cannot resolve the collation conflict

    今天遇到一个较为头痛的问题: Cannot resolve the collation conflict between "Chinese_PRC_90_CI_AS" and &q ...

  7. 解决SQL Server的cannot resolve the collation conflict问题

    当没有牵涉到两个不同的数据库时,出现以上错误.   Cannot resolve the collation conflict between "Chinese_PRC_CI_AS" ...

  8. 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 出错原因: ...

  9. 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 ...

随机推荐

  1. 学php之翻译wordpress(2)

    wp-load.php <?php /** * Bootstrap file for setting the ABSPATH constant * and loading the wp-conf ...

  2. HTML5图形绘制学习(1)-- Canvas 元素简介

    Canvas元素是HTML5中新增的一个专门用来进行图形绘制的元素.和其名称Canvas一样,它就相当于一个画布,我们可以在其上描绘各种图形. 这里所说的绘制图型,不是指我们可以进行可视化的图形绘制, ...

  3. zeromq-python使用

    安装参考saltstack编译安装.note 官方使用文档: http://zguide.zeromq.org/page:all 中文翻译文档: http://iyuan.iteye.com/blog ...

  4. 初学swift笔记 枚举(七)

    import Foundation /* 枚举 语法结构 enum 类型 { case 值 } */ //定义一个枚举 写法1 enum LiuShiQun { case Name case Age ...

  5. 匈牙利算法(素数伴侣(HW1112))

    #define _CRT_SECURE_NO_WARNINGS #include<iostream> #include<vector> #include<string&g ...

  6. C语言基础06

    函数: 一组特定功能的代码段,之所以使用函数,为了在文件多处需要同一段代码时可以多次重复利用,减少代码冗余. //函数的声明 返回值类型 函数名称 ( 数据类型 形参1,数据类型 ,形参2 ) ; / ...

  7. android TextView EditTextView一些技巧使用 (视图代码布局)

    android TextView 是最常用的控件 可以用作普通的显示,还可以用作有显示文字的按钮,用作有显示图片的图文组合 1. 图文组合 xml 中: <TextView android:id ...

  8. winform,wpf全屏 还显示任务栏的解决方法

    原文:winform,wpf全屏 还显示任务栏的解决方法 以wpf为例: 全屏代码: this.Topmost = true; this.WindowStyle = System.Windows.Wi ...

  9. thinkphp这样玩关联查询(实例教会你)

    thinkphp实例,内连接实现多表中同时查找,并存在了一个数组中,返回到模板中,模板中volist遍历即可使用多表中的字段 $row=M()->query("select realn ...

  10. python编辑器对比和推荐

    python编辑器对比和推荐   我先给一个初步的表格吧,大家如果有什么意见,或有补充,欢迎提出.有些我没有用过,先不写了.以下是我使用过的python IDE: 除了PythonWin, Visua ...