Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Formatting numbers

Status
Not open for further replies.

jballum

MIS
Jul 10, 2000
161
CA
Is there any way to format numbers located in the database so that when they have a different number of decimals on output the decimal will be lined up. Also, I need commas inserted in correct locations.

Example:

45256.1
12.567126
4998.0003
5

would show as

45,256.100000
12.567126
4,998.000300
5.000000

Having six decimal places is a valid amount in the database I am involved with.

I can grind it out using a lot of formatting functions for the one field but I was wondering if there was any quick way to do it.

Thanks,

JB
 
Hi,

Hope this helps...

DECLARE @myval decimal (5, 1),
@myval2 decimal (10, 6)


SET @myval = 193.5

SELECT @myval2 = CAST(CAST(@myval AS varbinary(20)) AS decimal(10,6))
SELECT @myval2

Tom
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top