Mogą to powodować spacje końcowe. W przypadku porównań ciągów są one ignorowane.
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*/