I've been having a look at Corey's code to replace multiple spaces with a single space:http://www.sqlteam.com/forums/topic.asp?TOPIC_ID=56195Is there any reason why:Replace(Replace(Replace(myCol, ' ', ' þ'), 'þ ', ''), 'þ', '')
should not have a DOUBLE expression in the first replace?Replace(Replace(Replace(myCol, ' ', ' þ'), 'þ ', ''), 'þ', '') ^^
otherwise I'm concerned that a) replacing a single space with ' þ' might cause an overflow and b) that I will be doing replaces of single instances where actually there is no work to do!I was then planning to use my Tally table to find the first character not used in the string, and use that for the "marker", and thus make a general purpose "replace duplicates" UDF.What's the most efficient way to do that?SELECT TOP 1 @charMarker = CHAR(MyNumber)FROM dbo.MyTallyTableWHERE mb_int_ID >= 65 -- Start at 'A' for this test AND CHARINDEX(CHAR(MyNumber), @strData) = 0
or should I use AND @strData NOT LIKE '%' + CHAR(MyNumber) + '%'
or something else?Do I need to start at ASCII 65 ('A') or are the ASCII values 0-31 just fine?ThanksKristen