I Have Temp table which contains the data which is imported from csv file, i want to remove the white space from the empty columns. tried with RTRIM(LTRIM(column)), it is just removing the leading and trailing spaces if string is not null.
0
votes
2 Answers
2
votes
I think the easiest way is to use REPLACE
:
SELECT REPLACE(' Test done ', ' ', '')
Or cascade of REPLACE
's:
DECLARE @text nvarchar(MAX)=N' Line test'+CHAR(13)+CHAR(10)+'done ';
SELECT REPLACE(REPLACE(REPLACE(@text, ' ', ''), CHAR(13), ''), CHAR(10), '')
The latter removes space, line feed and carriage return characters. Just expand expression to remove more white characters (i.e. tab).