I know about the CLR solution, but as I said, I am neither responsible nor authorized to implement it in the DB of question.
For this particular problem, I decided to write a very simple and kinda silly loop. I am afraid it won't be fast enough for millions of records, but anyways... I wish I could do this stuff in the application layer but I am bound to T-SQL here..
DECLARE @i int ; -- counter
DECLARE @input varchar(200) ;
SET @input = 'AAABCDEEFFBBBXYZSSSWWWNT'
IF LEN(@input) > 1
BEGIN
DECLARE @unduplicated varchar(200) ;
SET @unduplicated = SUBSTRING(@input,1,1) ;
SET @i = 2 ;
WHILE @i <= LEN(@input)
BEGIN
-- If current char is different from the last char, concatenate, else not
IF SUBSTRING(@unduplicated, LEN(@unduplicated), 1) <> SUBSTRING(@input, @i, 1)
SET @unduplicated = @unduplicated + SUBSTRING(@input, @i, 1) ;
SET @i = @i + 1;
END
END
SELECT @unduplicated AS unduplicated;
Result:
unduplicated
ABCDEFBXYZSWNT