“选择不同"忽略不同的情况 [英] "SELECT DISTINCT" ignores different cases

查看:26
本文介绍了“选择不同"忽略不同的情况的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我遇到了问题,MSSQL Server 2000 应该从表中选择一些不同的值(特定列是 nvarchar 类型).有时有相同的值,但情况不同,例如(伪代码):

I have the problem, that MSSQL Server 2000 should select some distinct values from a table (the specific column is of the nvarchar type). There are the sometimes the same values, but with different cases, for example (pseudocode):

SELECT DISTINCT * FROM ("A", "a", "b", "B")

会回来

A,b

但我确实想要(并且确实期待)

But I do want (and do expect)

A,a,b,B

因为它们实际上是不同的值.

because they actually are different values.

如何解决这个问题?

推荐答案

排序规则将设置为不区分大小写.

The collation will be set to case insensitive.

你需要做这样的事情

Select distinct col1 COLLATE sql_latin1_general_cp1_cs_as
From dbo.myTable

这篇关于“选择不同"忽略不同的情况的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆