请考虑以下几点:
IF OBJECT_ID('tempdb..#CharacterTest') IS NOT NULL
DROP TABLE #CharacterTest
CREATE TABLE #CharacterTest
(
[ID] int IDENTITY(1, 1) NOT NULL,
[CharField] varchar(50) NULL
)
INSERT INTO #CharacterTest (CharField)
VALUES ('DavidIsCool.')
, ('David')
, ('Bleh')
, ('Bleh')
, ('A')
, ('A')
, (' ')
, (' ')
, (' ')
, (' ')
, (' ');
Select count(*) RecordCount from #CharacterTest
SELECT DISTINCT CharField FROM #CharacterTest
SELECT count (DISTINCT CharField) FROM #CharacterTest
对于第二个和第三个查询,我总共返回了 5 个值。
为什么我的查询表明完全由空格组成的记录是相等的?这是由于排序规则设置吗?