且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

强制T-SQL查询在MS中区分大小写

更新时间:2023-02-05 22:37:26

select trans_type collate SQL_Latin1_General_CP1_CS_AS, count(*)
from mytable
group by trans_type collate SQL_Latin1_General_CP1_CS_AS

您可以使用 = like 和其他运算符来执行此操作。请注意,您必须修改选择列表,因为您不再按 trans_type 分组,而现在按 trans_type分组SQL_Latin1_General_CP1_CS_AS 。一种陷阱。

You can do this with =, like, and other operators as well. Note that you must modify the select list because you are no longer grouping by trans_type, you are now grouping by trans_type collate SQL_Latin1_General_CP1_CS_AS. Kind of a gotcha.