ibmi-brunch-learn

Announcement

Collapse
No announcement yet.

Removing Leading Zeros for a character field using SQL

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Removing Leading Zeros for a character field using SQL

    Hi Everyone,

    I have a file with a character field with the values like the following. I need to remove the leading zeros where the value is a all numeric. For example the first 3 values in Field A should be 44,62 and 380 while next 2 should appear as they are. I cannot use DEC key word in SQL because of the last 2 values. How do I do this in SQL 400?


    Field A
    000000000000000044
    000000000000000062
    000000000000000380
    80654000B
    Z1S7




    Appreciate help.

    Thanks in advance

    Surkum

  • #2
    Re: Removing Leading Zeros for a character field using SQL

    Try:
    Code:
    Select Trim(Leading '0' from YourField)
    From YourTable
    Birgitta

    Comment


    • #3
      Re: Removing Leading Zeros for a character field using SQL

      Thanks Birgitta. It worked perfectly.
      Appreciate your help.

      Comment

      Working...
      X