服务器和数据库的不同排序规则,哪个“更强”?
我有一个 sqlserver 2008 运行,排序规则设置为:Finnish_Swedish_CI_AS
我在该服务器上还有一个表,排序规则设置为:SQL_Latin1_General_CP437_CS_AS
在表中,我有一个名为 Material 的列,其中包含
abcf ABCF DF
SELECT Allowable FROM [Mat].[dbo].[D100601EN6115K3] WHERE Thickness = 2 AND CHARINDEX('F', Material)>0
它返回包含“f”或“F”的所有三行的允许值 如何使搜索区分大小写,以便只从最后一行获得允许的内容? 我希望有一个简单的方法,因为我不想再次设置整个服务器......
I have a sqlserver 2008 running with collation set to: Finnish_Swedish_CI_AS
I also have a table on that server with collation set to: SQL_Latin1_General_CP437_CS_AS
In the table I have a column named Material which contains
abcf
abcf
DF
SELECT Allowable FROM [Mat].[dbo].[D100601EN6115K3] WHERE Thickness = 2 AND CHARINDEX('F', Material)>0
It returns the allowable values for all three rows containing an "f" or "F"
How can I make my search case sensitive so that I only get the allowable from the last row?
I hope there is an easy way because I don't want to set up the whole server again...
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可以使用 COLLATE 子句更改表达式的排序规则
COLLATE 子句可以针对整个表达式或仅针对列引用。
如果 Material 已经具有排序规则 Material COLLATE SQL_Latin1_General_CP437_CS_AS 那么应该
抱歉,不能 100% 清楚哪一列是 CS: Material 或另一列。
基本上,
'F'
是服务器或数据库的排序规则(如果不同)You use the COLLATE clause to change the collation of the expression
The COLLATE clause can go against a whole expression or just a column reference.
If Material already has the collation Material COLLATE SQL_Latin1_General_CP437_CS_AS then it should be
Sorry, it isn't 100% clear which column is CS: Material or another one.
Basically,
'F'
is the collation of the server or database if different