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
 General SQL Server Forums
 New to SQL Server Programming
 trim spaces

Author  Topic 

amurark
Yak Posting Veteran

55 Posts

Posted - 2012-01-20 : 15:14:18
pls tell me how to trim trailing spaces as lrtrim ,rtrim is not working in slq server 2005.




Ankita

webfred
Master Smack Fu Yak Hacker

8781 Posts

Posted - 2012-01-20 : 15:20:45
They ARE working!
Maybe your spaces are no spaces?


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

sunitabeck
Master Smack Fu Yak Hacker

5155 Posts

Posted - 2012-01-20 : 15:24:09


LTRIM and RTRIM do work in SQL 2005 - if it looks like it is not working, it may be that they are not spaces, but other characters such as tab etc.?

You can cast to varbinary and see what the trailing/leading characters are, for example:
DECLARE @x1 VARCHAR(32), @x2 VARCHAR(32);
SET @x1 = 'abcd '; -- trailing space
SET @x2 = 'abcd '; -- trailing tab
SELECT CAST(@x1 AS VARBINARY),CAST(@x2 AS VARBINARY);

-- 0x6162636420 0x6162636409
-- Hex 20 is space and hex 09 is tab
Go to Top of Page

amurark
Yak Posting Veteran

55 Posts

Posted - 2012-01-21 : 08:19:28
thnks for replies
but it is not working i want to remove spaces or tabs

plssss help me

Ankita
Go to Top of Page

sunitabeck
Master Smack Fu Yak Hacker

5155 Posts

Posted - 2012-01-21 : 09:03:40
Can you post the query you are using, along with some sample data? Take a look at Brett's blog here for some guidance on how to post it.
Go to Top of Page

Kristen
Test

22859 Posts

Posted - 2012-01-21 : 09:28:59
" i want to remove spaces or tabs "

RTrim doesn't remove TABs.
Go to Top of Page
   

- Advertisement -