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 2008 Forums
 Transact-SQL (2008)
 REAL to FLOAT datatype conversion

Author  Topic 

Herleen Kaur
Starting Member

3 Posts

Posted - 2010-11-30 : 07:50:05
If I'll alter any existing table with columns having 'REAL' datatype by 'FLOAT' datatype, what will be this effect my data?

Lumbago
Norsk Yak Master

3271 Posts

Posted - 2010-11-30 : 08:27:26
No. They are synonyms so there will not be any change to the database whatsoever. Are you sure you want to use this data type though? Are you aware of the implications? What kind of data do you have in this column?

- Lumbago

My blog (yes, I have a blog now! just not that much content yet)
-> www.thefirstsql.com
Go to Top of Page

Michael Valentine Jones
Yak DBA Kernel (pronounced Colonel)

7020 Posts

Posted - 2010-11-30 : 10:27:31
REAL and FLOAT are not the same. A FLOAT (FLOAT(53)) can store any value a REAL (FLOAT(24)) can hold but not the other way around. FLOAT is a higher precision version of REAL.

REAL is a synonym of FLOAT(24) using 4 bytes of storage with a value range of -3.40E+38 to -1.18E-38, 0 and 1.18E-38 to 3.40E+38

FLOAT is a synonym of FLOAT(53) using 8 bytes of storeage with a value range of -1.79E+308 to -2.23E-308, 0 and 2.23E-308 to 1.79E+308




CODO ERGO SUM
Go to Top of Page

Lumbago
Norsk Yak Master

3271 Posts

Posted - 2010-11-30 : 10:43:22
Crap...I know I read in BOL that they were synonyms but I missed the (24)-part. Thanx for pointing it out! You learn something new every day... Although I hope I learned something else today as well that has more significance in my life than this

- Lumbago

My blog (yes, I have a blog now! just not that much content yet)
-> www.thefirstsql.com
Go to Top of Page

jcelko
Esteemed SQL Purist

547 Posts

Posted - 2010-11-30 : 10:49:55
quote:
Originally posted by Lumbago

Crap...I know I read in BOL that they were synonyms but I missed the (24)-part.


They were at one time in T-SQL, as I recall, back in the says of 16 bit UNIX hardware. In the ANSI/ISO Standards, there were differences because of binary versus base ten floating point numbers. But I would have to look them up; I tend to use DECIMAL(s,p) when I bigger or smaller numbers these days.

--CELKO--
Books in Celko Series for Morgan-Kaufmann Publishing
Analytics and OLAP in SQL
Data and Databases: Concepts in Practice
Data, Measurements and Standards in SQL
SQL for Smarties
SQL Programming Style
SQL Puzzles and Answers
Thinking in Sets
Trees and Hierarchies in SQL
Go to Top of Page
   

- Advertisement -