I have a REALLY odd one here.
I have 2 rows in a table where the data in the same column on running a SELECT query is identical bar a trailing space (or perhaps another whitespace char) in one of them. Column is declared varchar(max)
. I want to treat both values as the same (to do a GROUP BY, as it happens).
After RTRIM did not work, I looked at the varbinary of both ... and they are identical. But they are not, I can see a space and GROUP BY treats them as seperate values (that is my real problem).
I already tried replacing CHAR(13) - it is not that.
Any clues?
CODE:
declare @vals table
(
id int identity primary key,
textval varchar(max)
)
insert into @vals (textval) values ('07.09.17 Liefertermin weiterhin nicht bekannt (LZ Elmshorn)')
insert into @vals (textval) values ('07.09.17 Liefertermin weiterhin nicht bekannt (LZ Elmshorn)
')
select id, textval + '*' from @vals
select id, RTRIM(LTRIM(REPLACE(textval,CHAR(13),''))) + '*' from @vals
select textval from @vals group by textval