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 2000 Forums
 Transact-SQL (2000)
 Leading Zeros to Decimal Data Type

Author  Topic 

gtroya
Starting Member

3 Posts

Posted - 2009-03-24 : 14:26:17
Hello

I have a SQL table with one column that I need to format as follows:

My column name is: Diff_Adj

Data looks like this:
15.00 and -15.00
---Positive and Negative amounts in this column---

I need to remove decimal point so data will look like this:
1500 and -1500

Then I need to add leading zeros to them so all the amounts are in 10 dogits long including the negative sign for negative amounts

0000001500
-000001500

PLEASE HELP

dinakar
Master Smack Fu Yak Hacker

2507 Posts

Posted - 2009-03-24 : 14:29:07
all this formatting should be done at frontend using application language.. SQL is best at just returning values..

Dinakar Nethi
************************
Life is short. Enjoy it.
************************
http://weblogs.sqlteam.com/dinakar/
Go to Top of Page

dinakar
Master Smack Fu Yak Hacker

2507 Posts

Posted - 2009-03-24 : 14:50:16
If you have to do it in TSQL you can try something like this:
RIGHT('0000000000' + Replace(@i,'.', '') , 10)

Dinakar Nethi
************************
Life is short. Enjoy it.
************************
http://weblogs.sqlteam.com/dinakar/
Go to Top of Page

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2009-03-24 : 15:49:04
Asked before here
http://www.sqlteam.com/forums/topic.asp?TOPIC_ID=121901



E 12°55'05.63"
N 56°04'39.26"
Go to Top of Page
   

- Advertisement -