Jesse Meng
Jesse Meng

Reputation: 111

Removing leading zeroes in a select* SQL

I want to strip the leading zeroes in certain columns of my select statement. I know how to do this if the column names are listed:

For example, in SELECT a,b,c.... if I want to trim column b, I simply do

SELECT a, TRIM(LEADING '0' FROM b) new name, c.... 

Now I also want to do the same for a SELECT* statement.. Suppose I have SELECT *, and I want to trim the leading zeroes for column b only. Is there an alternative to go as to convert the SELECT * to a normal select by listing out all columns? It becomes tedious this way.

Upvotes: 1

Views: 21684

Answers (1)

Kris Rice
Kris Rice

Reputation: 3410

This has been answered here: Removing leading zeros from varchar sql developer

select ltrim('000012345', '0') from dual;

LTRIM
-----
12345

Upvotes: 3

Related Questions