添加链接
link管理
链接快照平台
  • 输入网页链接,自动生成快照
  • 标签化管理网页链接

This browser is no longer supported.

Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.

Download Microsoft Edge More info about Internet Explorer and Microsoft Edge Azure Synapse Analytics Analytics Platform System (PDW)

Approximate-number data types for use with floating point numeric data. Floating point data is approximate; therefore, not all values in the data type range can be represented exactly. The ISO synonym for real is float(24) .

Transact-SQL syntax conventions

Syntax

float [ ( n ) ] Where n is the number of bits that are used to store the mantissa of the float number in scientific notation and, therefore, dictates the precision and storage size. If n is specified, it must be a value between 1 and 53 . The default value of n is 53 .

n value Precision Storage size

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 .

The SQL Server float [ (n) ] data type complies with the ISO standard for all values of n from 1 through 53 . The synonym for double precision is float(53) .

To view Transact-SQL syntax for SQL Server 2014 and earlier, see Previous versions documentation .

Remarks

Data type Range Storage

Converting float and real data

Values of float are truncated when they are converted to any integer type.

When you want to convert from float or real to character data, using the STR string function is usually more useful than CAST( ). This is because STR enables more control over formatting. For more information, see STR (Transact-SQL) and Functions (Transact-SQL) .

Prior to SQL Server 2016 (13.x), conversion of float values to decimal or numeric is restricted to values of precision 17 digits only. Any float value less than 5E-18 (when set using either the scientific notation of 5E-18 or the decimal notation of 0.000000000000000005) rounds down to 0. This is no longer a restriction as of SQL Server 2016 (13.x).

See also

ALTER TABLE (Transact-SQL)
CAST and CONVERT (Transact-SQL)
CREATE TABLE (Transact-SQL)
Data Type Conversion (Database Engine)
Data Types (Transact-SQL)
DECLARE @local_variable (Transact-SQL)
SET @local_variable (Transact-SQL)