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
 Transact-SQL (2000)
 how can i remove a char from a data

Author  Topic 

-fred-
Starting Member

5 Posts

Posted - 2004-08-12 : 23:01:58
sorry for my slightly stupid question..hehe i'm just a newbie using ms-sql

how can i remove a certain character from the table?

example:

client_no
-------------
ALS186//E200
ARA269//E205

how can i update all those having 2 '/' in between..
i just want to remove the 2nd '/' between those characters..

hope you can help me..

tnx in advance..


kselvia
Aged Yak Warrior

526 Posts

Posted - 2004-08-12 : 23:56:56
This should work:

update mytable
set client_no = replace(client_no,'//','/')

--Ken
"Knowledge is a process of piling up facts; wisdom lies in their simplification."
Go to Top of Page

-fred-
Starting Member

5 Posts

Posted - 2004-08-13 : 01:19:32
oh ok.. hehe.. thank you so much..
Go to Top of Page

-fred-
Starting Member

5 Posts

Posted - 2004-08-13 : 03:29:42
another problem...hope anyone can help...
the same as above but the problem is i can't seem to replace the word "transfer to" to "tct"

exmaple:
client_name
-----------
phil/transfer to afp
transfer to jap
jap/transfer to jap

is used this code:
update mytable
set client_name = replace(client_no,'transfer to','tct')

yes, it worked but...
result:

client_name
-----------
phil/transfer to afp
tct jap
jap/transfer to jap


question: i don't know why it couldn't change all those "transfer"

thanks in advance...
Go to Top of Page

kselvia
Aged Yak Warrior

526 Posts

Posted - 2004-08-13 : 03:37:47
I assume you actually used client_name instead of client_no in the replace function.
Is it possible there are tabs or multiple spaces between some 'transfer' and 'to'?


--Ken
"Knowledge is a process of piling up facts; wisdom lies in their simplification."
Go to Top of Page

-fred-
Starting Member

5 Posts

Posted - 2004-08-13 : 04:01:02
oh sorry, typo-error...
my code was correct, i have just mis-typed when i post here..

code is used:
update mytable
set client_name = replace(client_name,'transfer to','tct')

is there any turn-around with regards to my problem...
Go to Top of Page

mr_mist
Grunnio

1870 Posts

Posted - 2004-08-13 : 04:15:07
That code is fine, what version of SQL are you using? Is it service packed? Otherwise like Ken says it is probably not a space in between transfer and to.

-------
Moo. :)
Go to Top of Page
   

- Advertisement -