Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Rplace sql query

Status
Not open for further replies.

sdnprs

MIS
Nov 6, 2002
1
US
How can I write a replace SQL query to replace a dash anywhere in a label field in a table with a space. The dash is an unsupported field and I have about 7000 records with dashes in various places within the particular field
 
update tab
set col =
substring(col from 1 for position ('-' in col) - 1)
|| ' ' ||
substring(col from position ('-' in col) + 1)
where position ('-' in col) > 0

repeat it until activity_count = 0

Dieter
 
If your dbms is Oracle you may try:

select Column1,
replace (Column1,'A','Z') New_Column1
from tablex

Giving:

Column1 New_Column1
--------- -----------------
ABC ZBC
CDB CDB
XYZ XYZ
AAA ZZZ

Cheers
AA 8~)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top