Skip to main content
Question

How to trim leading 0s

  • Jul 10, 2018 2:32 AM UTC
  • 2 replies
  • 15 views

Hello

I am having hard time finding code to remove leading zeros. An example of the string is '00001234' and '0012345'. I need to remove leading zeros to show '1234' and '12345' respectively. Any help?

Thanks
VJ

2 replies

SruthiA
Forum|alt.badge.img+1
  • Participating Frequently
  • Jul 10, 2018 3:12 AM UTC

Hi,

  Please check the below solution. 

dbadmin=>select trim(LEADING '0' FROM '00012345');

ltrim

12345
(1 row)

dbadmin=> select trim(LEADING '0' FROM '0000001234');

ltrim

1234
(1 row)


  • Author
  • New Participant
  • Jul 13, 2018 8:45 PM UTC

that worked, thank you very much