Mathematical Functions
The .NET Framework Data Provider for SQL Server (SqlClient) provides math functions that perform calculations on input values that are provided as arguments, and return a numeric value result. These functions are in the SqlServer namespace, which is available when you use SqlClient. A provider's namespace property allows the Entity Framework to discover which prefix is used by this provider for specific constructs, such as types and functions.The following table describes the SqlClient math functions.
Function | Description |
---|---|
ABS(expression) |
Performs the absolute value function. Arguments expression: An Int32, Int64, Double, or Decimal. Return Value The absolute value of the specified expression. Example
|
ACOS(expression) |
Returns the arccosine value of the specified expression. Arguments expression: A Double. Return Value A Double. Example
|
ASIN(expression) |
Returns the arcsine value of the specified expression. Arguments expression: A Double. Return Value A Double. Example
|
ATAN(expression) |
Returns the arctangent value of the specified numeric expression. Arguments expression: A Double. Return Value A Double. Example
|
ATN2(expression, expression) |
Returns the angle, in radians, whose tangent is between the two specified numeric expressions. Arguments expression: A Double. Return Value A Double. Example
|
CEILING(expression) |
Converts the specified expression to the smallest integer that is greater than or equal to it. Arguments expression: An Int32, Int64, Double, or Decimal. Return Value An Int32, Int64, Double, or Decimal. Example
|
COS(expression) |
Calculates the trigonometric cosine of the specified angle in radians. Arguments expression: A Double. Return Value A Double. Example
|
COT(expression) |
Calculates the trigonometric cotangent of the specified angle in radians. Arguments expression: A Double. Return Value A Double. Example
|
DEGREES(radians) |
Returns the corresponding angle in degrees. Arguments expression: An Int32, Int64, Double, or Decimal. Return Value An Int32, Int64, Double, or Decimal. Example
|
EXP(expression) |
Calculates the exponential value of a specified numeric expression. Arguments expression: A Double. Return Value A Double. Example
|
FLOOR(expression) |
Converts the specified expression to the largest integer less than or equal to it. Arguments expression: A Double. Return Value A Double. Example
|
LOG(expression) |
Calculates the natural logarithm of the specified float expression. Arguments expression: A Double. Return Value A Double. Example
|
LOG10(expression) |
Returns the base-10 logarithm of the specified Double expression. Arguments expression: A Double. Return Value A Double. Example
|
PI() |
Returns the constant value of pi as a Double. Return Value A Double. Example
|
POWER(numeric_expression, power_expression) |
Calculates the value of a specified expression to a specified power. Arguments numeric_expression: An Int32, Int64, Double, or Decimal. power_expression: A Double that represents the power to which to raise the numeric_expression. Return Value The value of the specified numeric_expression to the specified power_expression. Example
|
RADIANS(expression) |
Converts degrees to radians. Arguments expression: An Int32, Int64, Double, or Decimal. Return Value An Int32, Int64, Double, or Decimal. Example
|
RAND([seed]) |
Returns a random value from 0 through 1. Arguments Retruns the seed value as an Int32. If the seed is not specified, the SQL Server Database Engine assigns a seed value at random. For a specified seed value, the result returned is always the same. Return Value A random Double value from 0 through 1. Example
|
ROUND(numeric_expression, length [ ,function ]) |
Returns a numeric expression, rounded to the specified length or precision. Arguments numeric_expression: An Int32, Int64, Double, or Decimal. length: An Int32 that represents the precision to which numeric_expression is to be rounded. When length is a positive number, numeric_expression is rounded to the number of decimal positions specified by length. When length is a negative number, numeric_expression is rounded on the left side of the decimal point, as specified by length. function: (optional) An Int32 that represents the type of operation to perform. When function is omitted or has a value of 0 (default), numeric_expression is rounded. When a value other than 0 is specified, numeric_expression is truncated. Return Value The value of the specified numeric_expression to the specified power_expression. Example
|
SIGN(expression) |
Returns the positive (+1), zero (0), or negative (-1) sign of the specified expression. Arguments expression: Int32, Int64, Double, or Decimal Return Value An Int32, Int64, Double, or Decimal. Example
|
SIN(expression) |
Calculates the trigonometric sine of the specified angle in radians, and returns a Double expression. Arguments expression: A Double. Return Value A Double. Example
|
SQRT(expression) |
Returns the square root of the specified expression. Arguments expression: A Double. Return Value A Double. Example
|
SQUARE(expression) |
Returns the square of the specified expression. Arguments expression: A Double. Return Value A Double. Example
|
TAN(expression) |
Calculates the tangent of a specified expression. Arguments expression: Double Return Value Double Example
|
For more information about the mathematical functions that SqlClient supports, see the documentation for the SQL Server version that you specified in the SqlClient provider manifest:
SQL Server 2000 | SQL Server 2005 | SQL Server 2008 |
---|---|---|