使用排序规则。在下面的示例中,我使用了波兰排序规则,但您可以使用其他排序规则。
CI = 不区分大小写,AI = 不区分重音,CS = 区分大小写,AS = 区分重音
SELECT
ID,
FK1 COLLATE Polish_CI_AI,
FK2 COLLATE Polish_CI_AI,
FK3 COLLATE Polish_CI_AI,
COUNT(*) as duplicate
FROM Pilkada.dbo.Transaction
GROUP BY
ID,
FK1 COLLATE Polish_CI_AI,
FK2 COLLATE Polish_CI_AI,
FK3 COLLATE Polish_CI_AI
HAVING COUNT(*) >1
排序的例子
CREATE TABLE #t (
k1 varchar(10)
)
INSERT INTO #t VALUES ('Mars')
INSERT INTO #t VALUES ('mars')
INSERT INTO #t VALUES ('maRs')
INSERT INTO #t VALUES ('MARS')
SELECT *
FROM #t
WHERE k1 = 'mars'
SELECT k1 COLLATE Polish_CS_AS , COUNT(*)
FROM #t
GROUP BY
k1 COLLATE Polish_CS_AS
SELECT k1 COLLATE Polish_CI_AS , COUNT(*)
FROM #t
GROUP BY
k1 COLLATE Polish_CI_AS
DROP TABLE #t