home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.databases.ingres
- Path: sparky!uunet!cs.utexas.edu!sdd.hp.com!mips!darwin.sura.net!uvaarpa!cv3.cv.nrao.edu!mail-to-news-gateway
- From: CS_PAUL@GSBVAX.UCHICAGO.EDU (Paul Ford 312/702-0335)
- Subject: RE: String Substitution
- Message-ID: <920812122007.20a00063@GSBVAX.UCHICAGO.EDU>
- Sender: root@nrao.edu (Operator)
- Organization: National Radio Astronomy Observatory
- Date: Wed, 12 Aug 1992 17:20:07 GMT
- Lines: 37
-
- Michael McGarrigle writes:
-
- >We wish to replace all occurences of a "-" with a space in
- >the employee_name field in a table.
-
- It's ugly, but you can use the string functions left, right, locate, and
- length to do it.
-
- update employee
- set
- employee_name =
- left( employee_name, locate(employee_name,'-')-1)
- + ' '
- + right( employee_name, length(employee_name)-locate(employee_name,'-'))
- where
- employee_name like '%-%'
-
- This only takes care of the first '-'. The update has to be repeated
- until it affects 0 rows.
-
- Try a select first to convince yourself that it works:
-
- select fixed_name =
- left( employee_name, locate(employee_name,'-')-1)
- + ' '
- + right( employee_name, length(employee_name)-locate(employee_name,'-'))
- from employee
- where
- employee_name like '%-%'
-
- Paul Ford
- --------------------------------------------------------------------------
- GSB Computing Services 312.702.0335
- University of Chicago cs_paul@gsbvax.uchicago.edu
- 1101 E. 58th Street
- Chicago IL 60637
- --------------------------------------------------------------------------
-