Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How eliminate the tab space in the column in SQL Server 2008

I have an column with email in table customer where the data in the column contains special character: TAB

When I do a select, I need to remove the TAB space from that column.

Means there is an empty TAB space followed by the EmailID: xyz.com

I tried using the LTRIM and RTRIM but that does not work here.

like image 569
happysmile Avatar asked Oct 16 '12 03:10

happysmile


People also ask

How do I remove a tab character in SQL Server?

There are tabs in the source SQL table data. I want to clean these tabs and extra spaces (Transformations) before moving data to the fixed width flat file. You may use the Derived Transformation task. Option 2: Use Script Component in Transformation Mode or Source Mode and use the Trim() method available.

Does SQL trim remove tabs?

For anyone using SQL Server 2017 or newer Please note that the default behavior of TRIM is to remove only spaces, so in order to also remove the tabs and newlines (CR + LFs), you need to specify the characters FROM clause.


2 Answers

Try this code

SELECT REPLACE([Column], char(9), '') From [dbo.Table]  

char(9) is the TAB character

like image 186
KaR Avatar answered Sep 28 '22 16:09

KaR


UPDATE Table SET Column = REPLACE(Column, char(9), '') 
like image 32
Andrei Karcheuski Avatar answered Sep 28 '22 17:09

Andrei Karcheuski