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
how we can select two columns having different collation
提问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.
其中col1和col2是字符串并使用排序规则。
When I run the query it shows the error:
当我运行查询时,它显示错误:
- Cannot resolve collation conflict for column 1 in statement.
- Cannot resolve collation conflict for column 2 in statement.
- 无法解决语句中第 1 列的排序规则冲突。
- 无法解决语句中第 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

