DECLARE @text VARCHAR(100);
SET @text= ' set
nocounto
n
'
WHILE PATINDEX( '%['+char(32)+','+char(9)+','+char(10)+','+char(13)+']%', @text ) > 0
SET @text = REPLACE( @text, SUBSTRING( @text, PATINDEX( '%['+char(32)+','+char(9)+','+char(10)+','+char(13)+']%', @text ), 1 ),'')
SELECT (@text), len(@text)
I replace any space, tab, carriage return or line feed with an empty string in the above.
----------------------------------------------------