zoukankan      html  css  js  c++  java
  • 解决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--机构注册完成人数
        -------------报表需求字段-----------------
        );

    就能正常工作了。

  • 相关阅读:
    nginx相关参考博客
    MySQL workbench8.0 CE基本用法(创建数据库、创建表、创建用户、设置用户权限、创建SQL语句脚本)
    MySQL Workbench基本操作
    idea导入(import)项目和打开(open)项目的区别
    [铁道部信息化管理]需求分析(一)—— 售票系统领域知识(区间票、订票、预留票)
    [铁道部信息化管理]核心业务需求及逻辑架构分析
    【spring boot 系列】spring data jpa 全面解析(实践 + 源码分析)
    OOAD-设计模式(一)概述
    TKmybatis的框架介绍和原理分析及Mybatis新特性
    国内程序员的十大疑问之一:为什么老外不愿意用MyBatis?
  • 原文地址:https://www.cnblogs.com/tylertang/p/4958602.html
Copyright © 2011-2022 走看看