April 22, 2014 at 12:54 am
Hi
my problem is:
DECLARE @Price FLOAT
SET @Price=15000000
PRINT @p1
result:
1.5e+007
please help
tanks
April 22, 2014 at 1:08 am
First a question, is float the correct data type for the query, most certainly not if dealing with monetary values.
To print the number, you can use either the STR or the FORMAT functions:
DECLARE @Price FLOAT
SET @Price=15000000
PRINT STR(@Price,8)
PRINT FORMAT(@Price,'N')
Method OUTPUT
------ --------------
STR 15000000
FORMAT 15,000,000.00
😎
April 22, 2014 at 4:20 am
Use correct data types. If you need a floating point number, use a float. If you're expecting an integer, use one of the integer data types, not the float.
"The credit belongs to the man who is actually in the arena, whose face is marred by dust and sweat and blood"
- Theodore Roosevelt
Author of:
SQL Server Execution Plans
SQL Server Query Performance Tuning
April 22, 2014 at 11:47 am
You should certainly use the appropriate data types. That said - there's nothing mathematically wrong with the answer you got back. For one thing - you didn't specify a specific format you wanted returned, and 1.5E+07 is in fact correct.
Have you considered actually *formatting* the output to what you want it to be?
----------------------------------------------------------------------------------
Your lack of planning does not constitute an emergency on my part...unless you're my manager...or a director and above...or a really loud-spoken end-user..All right - what was my emergency again?
Viewing 4 posts - 1 through 3 (of 3 total)
You must be logged in to reply to this topic. Login to reply