Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

declare N in float in sql server 2008

I was reading http://msdn.microsoft.com/en-us/library/ms173773.aspx. There is a N in the float datatype. But, when I tried to declare N in float in SQL Server 2008, it didn't allow me. Where can I put the value for N? Thanks in advance.

like image 808
gmail user Avatar asked Oct 18 '25 15:10

gmail user


1 Answers

You can use

declare @x float(24) , @y float(53)

See the Note about other values of n

SQL Server treats n as one of two possible values. If 1<=n<=24, n is treated as 24. If 25<=n<=53, n is treated as 53.

real is synonymous with float(24) and float defaults to float(53)

Edit:

Regarding the comments. There is no point!, try the following.

CREATE TABLE FloatTest
(
x float(7),
y float(24),
z float(53)
)

Then refresh the list of tables and open the table designer. You will see SQL Server has just converted the first two columns to real and the last one to float anyway!

like image 139
Martin Smith Avatar answered Oct 22 '25 04:10

Martin Smith