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
 Is there any alter way to trim the column

Author  Topic 

subhaoviya
Posting Yak Master

135 Posts

Posted - 2009-07-29 : 05:28:23
while am using rtrim, ltrim in particular field to filter the space at both end. some of the columns wont get filtered. is there any to remove the space. rather than using this.

eg:
column name:"command"
column value:"hai "
query:
select rtrim(ltrim(command)) from mytable
result:
"hai "


thanks
subha

Mangal Pardeshi
Posting Yak Master

110 Posts

Posted - 2009-07-29 : 05:48:59
Subha,
What do you mean by " some of the columns wont get filtered"?

I guess rtrim(ltrim(command)) is the only option you have.

Mangal Pardeshi
http://mangalpardeshi.blogspot.com
Go to Top of Page

khtan
In (Som, Ni, Yak)

17689 Posts

Posted - 2009-07-29 : 06:23:47
it might not be space but some non-printable char like CR or LF. RTRIM() will not remove these.


KH
[spoiler]Time is always against us[/spoiler]

Go to Top of Page

subhaoviya
Posting Yak Master

135 Posts

Posted - 2009-07-30 : 00:28:24
then how to filter that non-printable characters?

thanks
subha
Go to Top of Page

GhantaBro
Posting Yak Master

215 Posts

Posted - 2009-07-30 : 00:31:33
do replace for all the char khtam suggested with nothing....
Go to Top of Page

subhaoviya
Posting Yak Master

135 Posts

Posted - 2009-07-30 : 00:39:59
hai friends i did that one. thanks khtan, you are exactly write, the char is CR. i used the replace method
replace(replace(replace(myfield,char(10),''),char(13),''),char(9),'')

thanks friends.........
Go to Top of Page
   

- Advertisement -