How to remove "Tab" from column data (SQL)

Problem:
Remove leading or trailing "Tab" from data values
Eg:
ColumnA

val1
val2
val3
val4
val5



So to remove these "tab" from data values we cannot use trim function directly


update testtable set ColumnA=trim(ColumnA);


Solution:
To solve this problem we can slightly modify the trim function and include Replace function also in it by specifying ascii value of "tab" which is 9.


update testtable set ColumnA=trim(replace(ColumnA,Char(9),Char(32)));

No comments:

Post a Comment