在 CONCAT 中使用整理

Use Collate in CONCAT(在 CONCAT 中使用整理)
本文介绍了在 CONCAT 中使用整理的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图连接 2 列,中间有一个空格,但出现整理错误:

SELECT DISTINCTp.PERSON_ID,p.ID_NUMBER,CONCAT(p.FULLNAMES, CONCAT(' ', p.SURNAME)) 作为名字,o.ORG_NAME,w.WARD_DESCRIPTION 作为病房,ess.DESCRIPTION 作为部门

<块引用>

无法解决concat操作中SQL_Latin1_General_CP1_CI_AS"和Latin1_General_CI_AS"之间的排序冲突

我的数据库中两个违规列的排序规则是:Latin1_General_CI_AS

然后我试图将空白整理到这个整理中,但我不知道如何做到这一点.我的尝试:

CONCAT(p.FULLNAMES, (CONCAT((COLLATE Latin1_General_CI_AS = ' '), p.SURNAME))) AS NAME,

什么的?

解决方案

您将 COLLATE 放在每个字段之后,即最坏的情况:

SELECT DISTINCTCONCAT(p.FULLNAMES COLLATE Latin1_General_CI_AS,(CONCAT(' ' COLLATE Latin1_General_CI_AS,p.SURNAME COLLATE Latin1_General_CI_AS))) AS NAME发件人 p

I was trying to concatonate 2 columns with a whitespace in between and got a collation error:

SELECT DISTINCT
    p.PERSON_ID,
    p.ID_NUMBER,
    CONCAT(p.FULLNAMES, CONCAT(' ', p.SURNAME)) AS NAME,
    o.ORG_NAME,
    w.WARD_DESCRIPTION AS WARD,
    ess.DESCRIPTION AS SECTOR

Cannot resolve the collation conflict between "SQL_Latin1_General_CP1_CI_AS" and "Latin1_General_CI_AS" in the concat operation

The collation of both the offending columns in my database is: Latin1_General_CI_AS

So then I was trying to collate the whitespace to this collation, but I have no idea how to do this. My attempt:

CONCAT(p.FULLNAMES, (CONCAT((COLLATE Latin1_General_CI_AS = ' '), p.SURNAME))) AS NAME,

or something?

解决方案

You put the COLLATE after each field, viz in the worst case scenario:

SELECT DISTINCT
    CONCAT(p.FULLNAMES COLLATE Latin1_General_CI_AS, 
      (CONCAT(' ' COLLATE Latin1_General_CI_AS, 
          p.SURNAME COLLATE Latin1_General_CI_AS))) AS NAME
FROM Person p

这篇关于在 CONCAT 中使用整理的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!

本站部分内容来源互联网,如果有图片或者内容侵犯您的权益请联系我们删除!

相关文档推荐

Execute complex raw SQL query in EF6(在EF6中执行复杂的原始SQL查询)
SSIS: Model design issue causing duplications - can two fact tables be connected?(SSIS:模型设计问题导致重复-两个事实表可以连接吗?)
SQL Server Graph Database - shortest path using multiple edge types(SQL Server图形数据库-使用多种边类型的最短路径)
Invalid column name when using EF Core filtered includes(使用EF核心过滤包括时无效的列名)
How should make faster SQL Server filtering procedure with many parameters(如何让多参数的SQL Server过滤程序更快)
How can I generate an entity–relationship (ER) diagram of a database using Microsoft SQL Server Management Studio?(如何使用Microsoft SQL Server Management Studio生成数据库的实体关系(ER)图?)