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
 General SQL Server Forums
 New to SQL Server Programming
 Number value changing to Scientific Notation

Author  Topic 

Grifter
Constraint Violating Yak Guru

274 Posts

Posted - 2012-09-11 : 04:36:37
I've got a number I am concatenating into a string in a procedure and when I do the insert in the procedure to the table it is displayed like:

1.53502e+006

but should be

1535016

I want to retain the second number format

My table data type for this field is FLOAT

What could I make it so that it doesn't do this?

G

sunitabeck
Master Smack Fu Yak Hacker

5155 Posts

Posted - 2012-09-11 : 07:27:20
I assume you are using CAST or CONVERT to change the FLOAT to a string. Instead, use STR function. http://msdn.microsoft.com/en-us/library/ms189527.aspx

For example, run this and you will see the difference:
declare @x float = 1535016;
SELECT 'This is a number:' + CAST (@x AS VARCHAR(32))
SELECT 'This is a number:' + STR(@x,18,0)
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2012-09-11 : 11:04:20
see this to understand how floating points are interpreted in sql server

http://visakhm.blogspot.com/2012/08/floating-point-formats-in-sql-server.html

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

Go to Top of Page
   

- Advertisement -