Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

SQL Server trim function

Tags:

sql-server

I have a problem in SQL Server. I want to remove space using Ltrim and Rtrim.

My query is like this

select len('test        ')

Return 6

select len(rtrim(ltrim('test        ')))

Return 6

Why Its not Removing space?

I have checked the ascii values for this space is 32.

Any help?

Thank you

like image 972
Sibiraj Avatar asked Mar 09 '26 18:03

Sibiraj


1 Answers

Because there are no spaces in this string - after test there are two horizontal tab characters (\t).

Tabs, not spaces

like image 112
Marek Grzenkowicz Avatar answered Mar 11 '26 12:03

Marek Grzenkowicz



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!