解决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.

今天在创建一个存储过程时出现错误提示:

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--机构注册完成人数
    -------------报表需求字段-----------------
    );

就能正常工作了。

转载于:https://www.cnblogs.com/tylertang/p/4958602.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值