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 2000 Forums
 SQL Server Administration (2000)
 hi

Author  Topic 

renu
Starting Member

47 Posts

Posted - 2008-04-01 : 01:14:15
i have to remove white space

eg>

select LTRIM[RE ]

I SHOULD GET THE OUTPUT LIKE [RE]

How can i achieve that

jackv
Master Smack Fu Yak Hacker

2179 Posts

Posted - 2008-04-01 : 01:54:41
I wasn't sure whether the [] were included ,if so then it's the first select


declare @var varchar(20)
SET @var = '[RE ]'

select replace(@var,' ','')


select ltrim(rtrim(@var))


Jack Vamvas
--------------------
Search IT jobs from multiple sources- http://www.ITjobfeed.com
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2008-04-02 : 02:53:45
quote:
Originally posted by jackv

I wasn't sure whether the [] were included ,if so then it's the first select


declare @var varchar(20)
SET @var = '[RE ]'

select replace(@var,' ','')


select ltrim(rtrim(@var))


Jack Vamvas
--------------------
Search IT jobs from multiple sources- http://www.ITjobfeed.com



Replace would do ltrim and rtrim also

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page

harsh_athalye
Master Smack Fu Yak Hacker

5581 Posts

Posted - 2008-04-02 : 06:11:29
I think Jack gave two different solutions, one when output includes square brackets and another one to trim trailing spaces when output does not include brackets.

Harsh Athalye
India.
"The IMPOSSIBLE is often UNTRIED"
Go to Top of Page
   

- Advertisement -