SQL 我们如何选择具有不同排序规则的两列

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/5387546/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-01 09:47:43  来源:igfitidea点击:

how we can select two columns having different collation

sql

提问by Akshara

I have an SQL query like

我有一个像 SQL 查询

SELECT Col1, Col2 FROM Table1
UNION ALL 
SELECT Col1, Col2 FROM Table2

where col1and col2are strings and using collations.

其中col1col2是字符串并使用排序规则。

When I run the query it shows the error:

当我运行查询时,它显示错误:

  1. Cannot resolve collation conflict for column 1 in statement.
  2. Cannot resolve collation conflict for column 2 in statement.
  1. 无法解决语句中第 1 列的排序规则冲突。
  2. 无法解决语句中第 2 列的排序规则冲突。

Any one please help.

任何人请帮忙。

回答by Coxy

Is the error a difference in case sensitivity between the two tables? That is the error that I have most often seen.
If so, collate the offending table back to good old Latin1_General_CI_ASor whatever else is most appropriate.

该错误是否是两个表之间区分大小写的差异?这是我最常看到的错误。
如果是这样,请将有问题的表格整理回原处Latin1_General_CI_AS或其他最合适的表格。

For example, if Table1 was case sensitive and you want to collate both tables as if they were case insensitive:

例如,如果 Table1 区分大小写并且您想要整理两个表,就好像它们不区分大小写一样:

SELECT Col1 COLLATE Latin1_General_CI_AS, 
       Col2 COLLATE Latin1_General_CI_AS FROM Table1
UNION ALL 
SELECT Col1, Col2 FROM Table2