解决SQL Server的cannot resolve the collation conflict问题
今天在创建一个存储过程时出现错误提示:
cannot resolve the collation conflict between "chinese_prc_ci_as" and "sql_latin1_general_cp1_ci_as" in the equal to operation
是一个字段的的collation设置为了sql_latin1_general_cp1_ci_as,执行下面的SQL,改为database_default即可:
ALTER TABLE blog_Content ALTER COLUMN SourceUrl nvarchar(200) COLLATE database_default NULL
转自:http://www.cnblogs.com/dudu/archive/2011/01/11/1933203.html
例如:
USE [febdb_HNA]
GO
/****** Object: StoredProcedure [dbo].[usp_Report_LoggedInAndSubmitted] Script Date: 11/12/2015 11:21:55 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO ALTER procedure [dbo].[usp_Report_LoggedInAndSubmitted]
@enrollmentId uniqueidentifier
as
--团险选择报告
begin
SET NOCOUNT ON;
--1、定义结果集
create table #tempLoggedInAndSubmittedReport
(
-------------报表需求字段-----------------
InstitutionCode nvarchar(50),--机构代码 COLLATE database_default null
PersonOfInstitution int,--机构人数
LoggedInPerson int,--机构登录人数
SubmittedPersion int--机构注册完成人数
-------------报表需求字段-----------------
);
--1 得到所有机构,及其总人数
insert into #tempLoggedInAndSubmittedReport(InstitutionCode,PersonOfInstitution)
(select distinct InstitutionCode,count(1) as PersonOfInstitution from Employee where Id in(select EmployeeId from EnrollmentEmployee where EnrollmentId=@enrollmentId)
group by InstitutionCode)
--2 得到登录员工
update a set a.LoggedInPerson=b.LoggedInPerson from #tempLoggedInAndSubmittedReport a join
(select distinct InstitutionCode,count(1) as LoggedInPerson from Employee where Id in
(select EmployeeId from EnrollmentEmployee where EnrollmentId=@enrollmentId and HasLoggedIn=1) group by InstitutionCode) b
on a.InstitutionCode=b.InstitutionCode
--3 得到注册完成员工
update a set a.SubmittedPersion=b.SubmittedPersion from #tempLoggedInAndSubmittedReport a join
(select distinct InstitutionCode,count(1) as SubmittedPersion from Employee where Id in
(select EmployeeId from EnrollmentEmployee where EnrollmentId=@enrollmentId and HasSubmitted=1) group by InstitutionCode) b
on a.InstitutionCode=b.InstitutionCode
--4、返回结果集
select InstitutionCode 机构代码,PersonOfInstitution 机构人数,LoggedInPerson 机构登录人数,SubmittedPersion 机构注册完成人数
from #tempLoggedInAndSubmittedReport order by 机构代码
drop table #tempLoggedInAndSubmittedReport
end不知道为什么在2012下会报错.
改动如下:
create table #tempLoggedInAndSubmittedReport
(
-------------报表需求字段-----------------
InstitutionCode nvarchar(50) COLLATE database_default null,--机构代码
PersonOfInstitution int,--机构人数
LoggedInPerson int,--机构登录人数
SubmittedPersion int--机构注册完成人数
-------------报表需求字段-----------------
);就能正常工作了。
解决SQL Server的cannot resolve the collation conflict问题的更多相关文章
- SQL Server, Cannot resolve the collation conflict
今天遇到一个较为头痛的问题: Cannot resolve the collation conflict between "Chinese_PRC_90_CI_AS" and &q ...
- SQL Server 问题之 排序规则(collation)冲突
一.写在前面 最近公司进行开发环境升级,数据库也准备了一个新的服务器,一切准备好后开始数据迁移,采取的方式为对现有Database(现有服务器Windows Server 2003 + SQL Ser ...
- 解决SQL Server管理器无法连接远程数据库Error: 1326错误
解决SQL Server管理器无法连接远程数据库Error: 1326错误 我们在在使用SQL Server时都会遇到使用SQL Server Management Studio无法连接远程数据库实例 ...
- 解决 SQL Server 所有帐号无 sysadmin 权限,且未启用 SQL Server 身份验证,sa 帐号也未启用的问题
解决 未启用 SQL Server 身份验证 的问题: 1. 运行 regedit,进入注册表编辑器 2. 打开:HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Micro ...
- 如何解决 SQL Server 中的锁升级所致的阻塞问题
概要 锁升级为表锁插入转换很多细粒度的锁 (如行或页锁) 的过程.Microsoft SQL Server 动态确定何时执行锁升级.作出决定之前,SQL Server 将特定的扫描,整个事务,并且用于 ...
- 解决Sql Server 日志满了,设置收缩
解决Sql Server 日志满了,设置收缩: --查看文件占用空间 . '文件大小(MB)',* from sysfiles; ALTER DATABASE SpyData SET RECOVERY ...
- 怎样解决SQL Server内存不断增加问题
原文:怎样解决SQL Server内存不断增加问题 版权声明:本文为博主原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接和本声明. 本文链接:https://blog.csdn. ...
- 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 "Chinese_PRC_CI_AS" and "SQL_L及由于排序规则不同导致查询结果为空的问题
报错:Cannot resolve the collation conflict between "Chinese_PRC_CI_AS" and "SQL_L 出错原因: ...
随机推荐
- CSU 1328: 近似回文词
省赛的A题...现场都没什么人做...其实就一暴力水题......坑死了... 1328: 近似回文词 Time Limit: 1 Sec Memory Limit: 128 MBSubmit: 1 ...
- UnicodeDecodeError: 'gbk' codec can't decode byte 0xff in position 0: illegal multibyte sequence
混淆了 python2 里边的 str 和 unicode 数据类型. 1. 对需要 str->unicode 的代码,可以在前边写上 import sys reload(sys) sys.se ...
- php导入导出cvs文件格式
1.导入 <?php header("Content-type: text/html; charset=gb2312"); $fname = $_FILES['myfile' ...
- 语义化HTML
一.怎样语义化html结构 语义化是指用合理HTML标签以及其特有的属性去格式化文档内容. 正确语义化----结构(html)才是重点,样式(css)是用来修饰结构的.所以要先确定html,确定标签, ...
- 关于NGUI与原生2D混用相互遮盖的问题心得
http://www.fzgh.org.cn/zuixindianying/144224.html Native2D自己可以使用Sort Layer来排序,每层又有不同的Order In Layer, ...
- iOS网络学习之“远离NSURLConnection 走进NSURLSession”
目前,在iOS的开发中,NURLConnection已经成为了过去式,现在的NSURLConnection已经deprected(iOS7之后),取而代之的是NSURLSession.而且AFNetw ...
- sql server 2008 R2 不允许保存更改,您所做的更改要求删除并重新创建以下表
点击菜单栏 [工具]->[选项] 进入如下界面: 将阻止保存要求重新创建表的更改 的勾去掉即可.
- [20160804]synchronized
class Timer{ private static int num; void add(String name){ //synchronized (this){ num++; try{ Threa ...
- POJ 1258
http://poj.org/problem?id=1258 今天晚上随便找了两道题,没想到两道都是我第一次碰到的类型———最小生成树.我以前并没有见过,也不知道怎么做,然后就看书,思路很容易理解 但 ...
- jsp调用java方法 function taglib
1.新建tld文件: my-functions.tld: <?xml version="1.0" encoding="UTF-8"?> <ta ...