Home:ALL Converter>T-SQL data type REAL FLOAT(n) on SQL Server

T-SQL data type REAL FLOAT(n) on SQL Server

Ask Time:2010-11-02T17:10:19         Author:mr.sverrir

Json Formatter

Is anyone aware of the reasons why the following line of T-SQL code works (under SQL Server 2008)?

SELECT cast(2 as real(10))

I expect the server to complain in the very same way it does when I attempt this:

declare @x real(10)
set @x  = 4.1234567
select @x

and I get:

Msg 2716, Level 16, State 1, Line 16
Column, parameter, or variable #2: Cannot specify a column width on data type real.

I realise that for MS SQL 2008 there is a data type REAL equivalent to FLOAT(24).

I just would like to know why CAST does not complain, i.e., it was possible to write nonsense as REAL(4,2) within CAST (under SQL 2000), it works fine with REAL(10) under SQL 2008 (again in CAST)?

Any suggestions and clarification appreciated. Thank you.

Author:mr.sverrir,eproduced under the CC 4.0 BY-SA copyright license with a link to the original source and this disclaimer.
Link to original article:https://stackoverflow.com/questions/4076225/t-sql-data-type-real-floatn-on-sql-server
yy