Survey
* Your assessment is very important for improving the work of artificial intelligence, which forms the content of this project
* Your assessment is very important for improving the work of artificial intelligence, which forms the content of this project
T-SQL Mathematical Functions Said Salomon Said Salomon Unitrin Direct Insurance [email protected] I have over 25 year experience IT. I have a vast array of abilities in the field in the areas of Network, Desktop Support, DBA, Staff Project Management, Application Software Development, Business Analysis and Quality Assurance. I have Microsoft certifications as MCTS, MCPS, and MCNPS, and multiple certifications from the Insurance Institute of America. Currently I am a DBA at Unitrin Direct Insurance. ABS DEGREES RAND ACOS EXP ROUND ASIN FLOOR SIGN ATAN LOG SIN ATN2 LOG10 SQRT CEILING PI SQUARE COS POWER TAN COT RADIANS A mathematical function that returns the absolute (positive) value of the specified numeric expression. Syntax: ABS ( numeric_expression ) Examples SELECT ABS(-1.0), ABS(0.0), ABS(1.0) A mathematical function that returns the angle, in radians, whose cosine is the specified float expression; also called arccosine. Syntax: ACOS ( float_expression ) Example: DECLARE @cos float; SET @cos = -1.0; SELECT 'The ACOS of the number is: ' + CONVERT(varchar, ACOS(@cos)); Returns the angle, in radians, whose sine is the specified float expression. This is also called arcsine. Syntax: ASIN ( float_expression ) Example: DECLARE @angle float SET @angle = -1.00 SELECT 'The ASIN of the angle is: ' + CONVERT(varchar, ASIN(@angle)) Returns the angle in radians whose tangent is a specified float expression. This is also called arctangent. Syntax: ATAN ( float_expression ) Example: SELECT 'The ATAN of -45.01 is: ' + CONVERT(varchar, ATAN(-45.01)) Returns the angle, in radians, between the positive x-axis and the ray from the origin to the point (y, x), where x and y are the values of the two specified float expressions. Syntax: ATN2 ( float_expression , float_expression ) Example: DECLARE @x float; DECLARE @y float SET @x = 35.175643; SET @y = 129.44 SELECT 'The ATN2 of the angle is: ' + CONVERT(varchar,ATN2(@x,@y )) Returns the smallest integer greater than, or equal to, the specified numeric expression. Syntax: CEILING ( numeric_expression ) Example: SELECT CEILING($123.45), CEILING($-123.45), CEILING($0.0) Is a mathematical function that returns the trigonometric cosine of the specified angle, in radians, in the specified expression. Syntax: COS ( float_expression ) Example: DECLARE @angle float SET @angle = 14.78 SELECT 'The COS of the angle is: ' + CONVERT(varchar,COS(@angle)) A mathematical function that returns the trigonometric cotangent of the specified angle, in radians, in the specified float expression. Syntax: COT ( float_expression ) Example: DECLARE @angle float SET @angle = 124.1332 SELECT 'The COT of the angle is: ' + CONVERT(varchar,COT(@angle)) Returns the corresponding angle in degrees for an angle specified in radians. Syntax: DEGREES ( numeric_expression ) Example: SELECT 'The number of degrees in PI/2 radians is: ' + CONVERT(varchar, DEGREES((PI()/2))); Returns the exponential value of the specified float expression. Syntax: EXP ( float_expression ) Example: SELECT EXP( LOG(20)), LOG( EXP(20)) Returns the largest integer less than or equal to the specified numeric expression. Syntax: FLOOR ( numeric_expression ) Example: SELECT FLOOR(123.45), FLOOR(-123.45), FLOOR($123.45) Returns the natural logarithm of the specified float expression. Syntax: LOG ( float_expression ) Example: SELECT LOG (EXP (10)); Returns the base-10 logarithm of the specified float expression. Syntax: LOG10 ( float_expression ) Example: SELECT POWER (10, LOG10(5)); Returns the constant value of PI. Syntax: PI ( ) Example: SELECT PI() Returns the value of the specified expression to the specified power. Syntax: POWER ( float_expression , y ) Example: SELECT POWER(2.0, -100.0); Returns radians when a numeric expression, in degrees, is entered. Syntax: RADIANS ( numeric_expression ) Example: SELECT RADIANS(1e-307) Returns a pseudo-random float value from 0 through 1, exclusive. Syntax: RAND ( [ seed ] ) Example: SELECT RAND(100), RAND(), RAND() Returns a numeric value, rounded to the specified length or precision. Syntax: ROUND ( numeric_expression , length [ ,function ]) Example: SELECT ROUND(123.9994, 3), ROUND(123.9995, 3) SELECT ROUND(150.75, 0, 1); Returns the positive (+1), zero (0), or negative (-1) sign of the specified expression. Syntax: SIGN ( numeric_expression ) Example: SELECT SIGN(-10), SIGN(10), SIGN(0) Returns the trigonometric sine of the specified angle, in radians, and in an approximate numeric, float, expression. Syntax: SIN ( float_expression ) Example: DECLARE @angle float SET @angle = 45.175643 SELECT 'The SIN of the angle is: ' + CONVERT(varchar,SIN(@angle)) Returns the square root of the specified float value. Syntax: SQRT ( float_expression ) Example: SELECT SQRT(64) Returns the square of the specified float value. Syntax: SQUARE ( float_expression ) Example: SELECT SQUARE(8) Returns the tangent of the input expression. Syntax: TAN ( float_expression ) Example: SELECT TAN(PI()/2); Demo Mathematical Functions (books Online) http://bit.ly/aHgLEo SQL Authority http://bit.ly/bqQQmK SQL Server 2008, Dev Edition http://bit.ly/L2hJQ My Twitter SaidSalomon