Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2008 Forums
 Transact-SQL (2008)
 Left padding an amount by zeros

Author  Topic 

shantanu88d
Starting Member

35 Posts

Posted - 2011-05-19 : 00:40:06
Hi,
I have an amount column which is of decimal datatype (ofcourse ).
I want to left pad value of this column, so that each value will be of 18 digits.

I tried this
SELECT REPLACE((RIGHT('00000' + RTRIM(bill_paid), 18)),'.','') FROM bill_info

But, the number of zeros is static. Whatever the amount be, that amount should get such numbers of zeros that entire amount is pf 18 digits.

Please help !

There are no failures...only experiences!

webfred
Master Smack Fu Yak Hacker

8781 Posts

Posted - 2011-05-19 : 02:45:34
SELECT REPLACE((RIGHT(replicate('0',18) + RTRIM(bill_paid), 18)),'.','')


No, you're never too old to Yak'n'Roll if you're too young to die.
Go to Top of Page
   

- Advertisement -