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 Development (2000)
 Replace string query

Author  Topic 

daveyt
Starting Member

2 Posts

Posted - 2005-01-07 : 10:27:51
I know i should be able to figure this out but I'm struggling.

I have a field called 'address' and it contains data in the format

"172.26.24.156,40101"

its a char field. I need to replace the first part - ie before the comma but
leave the second part intact. The end result being
(eg) "172.26.55.23,40101"

Ie variable length '1st part', the comma and the 2nd part unchanged.

Using instr and substr I'm struggling. Can someone help me out?

thanks
dave

daveyt
Starting Member

2 Posts

Posted - 2005-01-07 : 10:52:03
Answered my own query...

update table1
set address=REPLACE(address, "old bit", "new bit")
go

How stupid do I feel....

dave
Go to Top of Page

spirit1
Cybernetic Yak Master

11752 Posts

Posted - 2005-01-07 : 10:54:01
replce it where?
in sql:
select replace('172.26.24.156,40101',
left('172.26.24.156,40101', charindex(',', '172.26.24.156,40101')-1)
, '172.26.55.23')
in
VB
Replace('172.26.24.156,40101',
left('172.26.24.156,40101', Instr('172.26.24.156,40101', ',')-1)
, '172.26.55.23')


Go with the flow & have fun! Else fight the flow
Go to Top of Page
   

- Advertisement -