Wednesday, September 15, 2010

NUMERIC Function in Transact-SQL.

In this article We will learn how to use numeric function in transact-SQL.
ABS(n) Function: Return the absolute values of the numeric expression n.
SYNTAX:
ABS(n)  
n is the numeric expression and return the same type as numeric expression.
For example:
USE master
go
DECLARE @value float
SET @value = -45.34
SELECT 'The value of the ABS function is: ' + CONVERT(varchar,abs(@value))
GO

Output:

abs.gif 

ACOS(n) Function: A mathematical function that calculate the arc cosine of n. n as well as the resulting value belonging to the FLOAT data type.

SYNTAX:
ACOS(n)
n is the float expression and return the same type as float expression.
For example:
USE master
go
DECLARE @cos float
SET @cos  = -45.00
SELECT 'The ACOS of the number is: ' + CONVERT(varchar,abs(@cos))
GO

OUTPUT:

acos.gif

ASIN(n) Function: A mathematical function that calculate the arc sine of n. n as well as the resulting value belonging to the FLOAT data type.
SYNTAX:
ASIN(n)
n is the float expression and return the same type as float expression.
For example:
USE master
go
DECLARE @angle float
SET @angle  = 1.00
SELECT 'The ASIN of the angle is: ' + CONVERT(varchar,ASIN(@angle))
GO

OUTPUT:

asin.gif

CEILING(n): Ceiling return the smallest integer value greater or equal to the specified value n.

SYNTAX:

CEILING(n)

n is the numeric expression and return the same type as numeric expression.

For example:

USE master
go
select CEILING (24.78),CEILING (-24.78),CEILING (0.0)
go
OUTPUT:

 ceiling.gif

No comments:

Post a Comment