remove decimal and pad with zeros.

Experts:  I need t-sql in a select statement to
1. remove a decimal
2. and pad the number with zeros to a set number of 9 characters.

Example of values in field: sMTD
152.25   should be 000015225
12646.25 should be 001264625
1366.54 should be 000136654
13.05 should be 000001305
Who is Participating?
Dale BurrellDirectorCommented:
Something like

  replicate('0', 9-len(replace(convert(varchar,MyField),'.',''))) + replace(convert(varchar,MyField),'.','')
from MyTable
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.