Solved

how to pad zero's

Posted on 2002-05-06
5
331 Views
Last Modified: 2008-03-10
Hello,
How do I get my select to return .500 as opposed to .5?

tks

steve
0
Comment
Question by:stmontgo
5 Comments
 
LVL 6

Accepted Solution

by:
acampoma earned 25 total points
ID: 6991917
convert to char
so if you had .5
select right(left(rtrim(convert (char(20),.5))+'0000000',5),4)
0
 
LVL 6

Assisted Solution

by:curtis591
curtis591 earned 25 total points
ID: 6992316
To leave it as a number so it is easier to work with you can do the following.

declare @test as numeric(18,1)
set @test = .5
select cast(@test as numeric(18,3))
0
 

Expert Comment

by:dkfrizzell2
ID: 6995627
Are you returning the results in asp?  if so, you could pull if from the database as it is (.5) then just format it to display as you want...

so instead of (where VarMyFloat = .5):
<% Response.Write(VarMyFloat) %>

you could try:

<% Response.Write(FormatNumber(VarMyFloat),3)) %>

which would just tell it to format the number to display out to 3 decimal places.


0
 

Expert Comment

by:CleanupPing
ID: 9280536
stmontgo:
This old question needs to be finalized -- accept an answer, split points, or get a refund.  For information on your options, please click here-> http:/help/closing.jsp#1 
EXPERTS:
Post your closing recommendations!  No comment means you don't care.
0

Featured Post

Best Practices: Disaster Recovery Testing

Besides backup, any IT division should have a disaster recovery plan. You will find a few tips below relating to the development of such a plan and to what issues one should pay special attention in the course of backup planning.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Nowadays, some of developer are too much worried about data. Who is using data, who is updating it etc. etc. Because, data is more costlier in term of money and information. So security of data is focusing concern in days. Lets' understand the Au…
Introduction In my previous article (http://www.experts-exchange.com/Microsoft/Development/MS-SQL-Server/SSIS/A_9150-Loading-XML-Using-SSIS.html) I showed you how the XML Source component can be used to load XML files into a SQL Server database, us…
This video shows, step by step, how to configure Oracle Heterogeneous Services via the Generic Gateway Agent in order to make a connection from an Oracle session and access a remote SQL Server database table.
Viewers will learn how to use the UPDATE and DELETE statements to change or remove existing data from their tables. Make a table: Update a specific column given a specific row using the UPDATE statement: Remove a set of values using the DELETE s…

777 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question