Icon View Thread

The following is the text of the current message along with any replies.
Messages 1 to 3 of 3 total
Thread SQL Trim
Wed, Aug 12 2009 11:22 PMPermanent Link

"John Postnikoff"
Hello,

I would like to trim  (remove) the leading two characters in a field for all
records of a table. e.g. for example AB1 to 1. There could be over thirty
different combinations or unknown suffixes to AB , which could be characters
or numbers.  e.g. ABTest. AB123. so a simple UPDATE will not suffice. I
could not seem get TRIM to work.

To further clarify the table name is ORDERS the field is called REF.  I have
done it with Delphi strings but not with records of a database, or SQL. Any
help is appreciated.

John P.

Thu, Aug 13 2009 2:47 AMPermanent Link

Roy Lambert

NLH Associates

Team Elevate Team Elevate

John


Untested

UPDATE orders SET REF = SUBSTR(REF,3,999) WHERE REF LIKE 'AB%'

you can set it up as a script or a a paramterised query or something like

UPDATE orders SET REF = SUBSTR(REF,3,999) WHERE REF LIKE 'AB%' OR REF LIKE 'GB%' etc

Roy Lambert [Team Elevate]
Thu, Aug 13 2009 9:01 AMPermanent Link

"Robert"

"John Postnikoff" <john@trackinfosystems.net> wrote in message
news:03DAE8F6-1CD2-4F76-8233-8D8BF41F33BC@news.elevatesoft.com...
> Hello,
>
> I would like to trim  (remove) the leading two characters in a field for
> all
> records of a table. e.g. for example AB1 to 1. There could be over thirty
> different combinations or unknown suffixes to AB , which could be
> characters
> or numbers.  e.g. ABTest. AB123. so a simple UPDATE will not suffice. I
> could not seem get TRIM to work.
>
> To further clarify the table name is ORDERS the field is called REF.  I
> have
> done it with Delphi strings but not with records of a database, or SQL.
> Any
> help is appreciated.
>

UPDATE ORDERS SET REF = SUBSTRING(REF from 3)

Robert

Image