当没有牵涉到两个不同的数据库时,出现以上错误.
Cannot resolve the collation conflict between "Chinese_PRC_CI_AS" and "SQL_Latin1_General_CP1_CI_AS" in the equal to operation.
今天在创建一个存储过程时出现错误提示:
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--机构注册完成人数 -------------报表需求字段----------------- );就能正常工作了。