Approximate Numeric Literals in SQL Server Transact-SQL

Q

What are approximate numeric literals supported in SQL Server Transact-SQL?

✍: FYIcenter.com

A

Approximate numeric literals in Transact-SQL are numbers written in scientific notation formats.

Approximate numeric literals are used to provide values to approximate numeric variables or table columns like LOAT(24), DOUBLE PRECESSION, etc.

Approximate numeric literals are also used in approximate numeric operations in expressions and approximate numeric arguments in functions.

Here are some simple rules on how to write approximate numeric literals:

  • An approximate numeric literal should start with the sign mark, + or -, followed by the integer part, the decimal mark, the fractional part, and the exponential part.
  • The exponential part is always required and starts with e or E, followed by a signed integer.
  • The exponent of E0 can be written as E.

Here are some example on how to write exact numeric literals:

-- Identical approximate numeric literals
PRINT 9E0;
PRINT 9E;
PRINT 9E+;
PRINT 9E-;

-- Approximate numeric literal as function argument
PRINT SQRT(2.5E+1);

 

Binary Literals in SQL Server Transact-SQL

Exact Numeric Literals in SQL Server Transact-SQL

Data Literals in SQL Server Transact-SQL

⇑⇑ SQL Server Transact-SQL Tutorials

2017-05-05, 1769🔥, 0💬