Home » RDBMS Server » Server Administration » sql script help !!!
sql script help !!! [message #372989] Wed, 21 March 2001 07:44 Go to next message
Arpit
Messages: 99
Registered: March 2001
Member
Hi,

Can someone please help with with this.

I need to replace all occurences of 'ST' with "St." in my address_1 field for all the records. How can I do it? I have 'ST' before the acutal name as well as after the name. I need to replace only the ones before the actual name
100 ST Joseph ST ---> 100 St.Joseph ST
301 ST Paul ST -----> 301 St. Paul ST

Please help !
Thanks,
Alpesh
Re: sql script help !!! [message #372990 is a reply to message #372989] Wed, 21 March 2001 08:47 Go to previous messageGo to next message
ramu
Messages: 82
Registered: February 2001
Member
What a fantastic question was asked by you..

Try this query..

update table_name set column_name=(replace(substr(column_name,1,2),'ST','St')||substr(column_name,3));
Re: sql script help !!! [message #372992 is a reply to message #372990] Wed, 21 March 2001 10:47 Go to previous messageGo to next message
Arpit
Messages: 99
Registered: March 2001
Member
Thanks for your help.

I tried the above script, but it complaints that the second substring used requires three arguments.

Any input on this ?

Thanks!
Re: sql script help !!! [message #373038 is a reply to message #372990] Fri, 23 March 2001 12:00 Go to previous messageGo to next message
ramu
Messages: 82
Registered: February 2001
Member
Hi,

While using the substr, give the disired character place in the argument..If you want to take the characters from 1 to 3 then pass 1,3..like this..

Thanks..
Ramu..
Re: sql script help !!! [message #373039 is a reply to message #372990] Fri, 23 March 2001 12:01 Go to previous message
ramu
Messages: 82
Registered: February 2001
Member
Hi,

While using the substr, give the disired character place in the argument..If you want to take the characters from 1 to 3 then pass 1,3..like this..

Thanks..
Ramu..
Previous Topic: SUBQUERY
Next Topic: Re: converting Access query to SQL (for oracle)
Goto Forum:
  


Current Time: Wed Jun 26 06:56:26 CDT 2024