|
Home >> FAQs/Tutorials >> SQL Server FAQ
SQL Server FAQ - Mathematical Functions Supported by SQL Server 2005
By: FYIcenter.com
(Continued from previous topic...)
What Are the Mathematical Functions Supported by SQL Server 2005?
SQL Server 2005 supports 23 mathematical functions: ABS, ACOS, ASIN, ATAN, ATN2, CEILING,
COS, COT, DEGREES, EXP, FLOOR, LOG, LOG10, PI, POWER, RADIANS, RAND, ROUND, SIGN, SIN, SQRT, SQUARE, and TAN.
The return data types of mathematical functions are determined by two rules:
-- ABS retuns the same data type as the input
DECLARE @x FLOAT(53);
DECLARE @y NUMERIC(9,2);
DECLARE @z INT;
SET @x = -12345.123456789E+20;
SET @y = -12345.12;
SET @z = -12345
SELECT ABS(@x);
SELECT ABS(@y);
SELECT ABS(@z);
GO
1.2345123456789E+24
12345.12
12345
-- SQRT converts input to FLOAT(53) first
DECLARE @x FLOAT(53);
DECLARE @y NUMERIC(9,2);
DECLARE @z INT;
SET @x = 12345.123456789E+20;
SET @y = 12345.12;
SET @z = 12345
SELECT SQRT(@x);
SELECT SQRT(@y);
SELECT SQRT(@z);
GO
1111086110829.8
111.108595527079
111.108055513541
(Continued on next topic...)
- What Is an Expression?
- What Are Arithmetic Operators?
- What Happens to an Arithmetic Operation with Two Different Data Types?
- How To Convert a Numeric Expression from One Data Type to Another?
- How To Convert Numeric Expression Data Types by Assignment Operations?
- How To Convert Numeric Expression Data Types using the CAST() Function?
- How To Convert Numeric Expression Data Types using the CONVERT() Function?
- How To Convert Character Strings into Numeric Values?
- What Happens When Converting Big Values to Integers?
- What Happens When Converting Big Values to NUMERIC Data Types?
- What Are the Mathematical Functions Supported by SQL Server 2005?
- How To Convert Numeric Values to Integers?
- How To Round a Numeric Value To a Specific Precision?
- How To Generate Random Numbers with the RAND() Function?
|