Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2008 Forums
 Transact-SQL (2008)
 Trim 'tab' blank(rather than 'space' blank)

Author  Topic 

Oliver wang
Yak Posting Veteran

50 Posts

Posted - 2011-01-10 : 07:13:19
Hi everyone,

if I want to trim 'tab' blank in a string in SQL Server, is there any build-in function that can implement that? I have tried Ltrim(Rtrim(string)), but that doesn't work. Thanks.

regards,

Oliver

webfred
Master Smack Fu Yak Hacker

8781 Posts

Posted - 2011-01-10 : 07:30:56
You can use REPLACE() together with CHAR(9) but that will replace all tabs and not only leading and trailing tabs.

REPLACE(YourString,CHAR(9),'')


No, you're never too old to Yak'n'Roll if you're too young to die.
Go to Top of Page

Ifor
Aged Yak Warrior

700 Posts

Posted - 2011-01-10 : 08:49:38
To elaborate on WebFred’s response:

SELECT LEFT(YourString, LEN(REPLACE(YourString, CHAR(9), ' ')));
Go to Top of Page
   

- Advertisement -