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
 Remove Sapces

Author  Topic 

kiruthika
Yak Posting Veteran

67 Posts

Posted - 2008-01-04 : 04:51:26
Hi!

create table login1(userid varchar(20),pass varchar(20))
insert login1 values('kee rthi @ gmail.com', 'keerthi')
insert login1 values('aji@gmail.com', 'aji')
insert login1 values('aaa@gmail.com', 'aaa')
insert login1 values('bb b@gmail.com', 'bbb')

select * from login1

I want to remove the spaces between userid field like(keerthi@gmail.com)

output:
userid
----------
keerthi@gmail.com
aji@gmail.com
aaa@gamil.com
bbb@gamil.com

I tried this querey but not working
select replace(userid,'','') as userid from login1

How can i acheive this? Please help me
Thanks!

harsh_athalye
Master Smack Fu Yak Hacker

5581 Posts

Posted - 2008-01-04 : 05:11:24
[code]select replace(userid,Char(32),'') as userid from login1[/code]

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

ditch
Master Smack Fu Yak Hacker

1466 Posts

Posted - 2008-01-04 : 05:14:44
also those so called spaces might not be spaces Char(32) they could be Char(0) or something similar - because the replace using ' ' should do the trick.


Duane.
Go to Top of Page

kiruthika
Yak Posting Veteran

67 Posts

Posted - 2008-01-04 : 05:29:15
quote:
Originally posted by harsh_athalye

select replace(userid,Char(32),'') as userid from login1


Harsh Athalye
India.
"The IMPOSSIBLE is often UNTRIED"



Thanks Harsh and Ditch!Thank You so much!

kiruthika!
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2008-01-04 : 07:41:57
quote:
Originally posted by kiruthika

Hi!

create table login1(userid varchar(20),pass varchar(20))
insert login1 values('kee rthi @ gmail.com', 'keerthi')
insert login1 values('aji@gmail.com', 'aji')
insert login1 values('aaa@gmail.com', 'aaa')
insert login1 values('bb b@gmail.com', 'bbb')

select * from login1

I want to remove the spaces between userid field like(keerthi@gmail.com)

output:
userid
----------
keerthi@gmail.com
aji@gmail.com
aaa@gamil.com
bbb@gamil.com

I tried this querey but not working
select replace(userid,'','') as userid from login1

How can i acheive this? Please help me
Thanks!


Also select replace(userid,'','') as userid from login1 wont do anything. You forget to specify space


Madhivanan

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

- Advertisement -