Skip to content

“It works, just not for the reason you think”

November 4, 2010

A somewhat mistaken attempt to format a number left-padded with up to six zeroes, made me cringe a little:

SELECT LPAD(number_column, 6, 000000) FROM ...

Yes, it does work (the domain of number_column is limited to positive integers), but not for the reason the writer thought, I think.

(Hint: what is the data type of the third parameter to LPAD?)

About these ads

From → SQL

Comments are closed.

Follow

Get every new post delivered to your Inbox.

Join 215 other followers

%d bloggers like this: