Achterliggende spaties kunnen dit veroorzaken. Voor stringvergelijkingen worden deze genegeerd.
CREATE TABLE #T
(
a varchar(10),
b varchar(10),
c varchar(10)
)
INSERT INTO #T
SELECT 'a ' as a, 'b' as b, 'c ' as c union all
SELECT 'a' as a, 'b' as b, 'c ' as c
SELECT DISTINCT a, b, c
FROM #T /*1 result*/
SELECT DISTINCT a + '|' + b + '|' + c + '|'
FROM #T /*2 results*/
SELECT DISTINCT LTRIM(RTRIM(a)) + '|' + LTRIM(RTRIM(b)) + '|' +
LTRIM(RTRIM(c)) + '|'
FROM #T /*1 result*/