0% found this document useful (0 votes)
4 views6 pages

Labone

The document provides instructions on how to use built-in mathematical functions in SQL Server, including examples for functions like ABS, CEILING, FLOOR, POWER, SQUARE, and SQRT. It also demonstrates how to generate random numbers and round or truncate decimal values. Additionally, a loop is included to print 10 different random values between 1 and 100.

Uploaded by

yohbog123
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
4 views6 pages

Labone

The document provides instructions on how to use built-in mathematical functions in SQL Server, including examples for functions like ABS, CEILING, FLOOR, POWER, SQUARE, and SQRT. It also demonstrates how to generate random numbers and round or truncate decimal values. Additionally, a loop is included to print 10 different random values between 1 and 100.

Uploaded by

yohbog123
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 6

how to use builtin function in sql

server
• To see all built-in mathematical function
• navigate on sql server and expand sql database folder-->expand your database--
>expand programmability-->expand functions--expand system functions and
Mathematical functions
• -- Absolut value of any negative number
• select abs(-101.5)
• --ceiling the next highest number
• select CEILING(15.2)
• -- the next lower number
• select FLOOR(1.5)
• --select power of any two number
• select power(2,3)
• -- square of any number
• select SQUARE(9)
• --select square root of any number
• select SQRT(80)
• --select any random number between 0&1
• select rand()
• --return always the same value of rand
• select rand(1)
• --select randum between 1&100
• select CEILING(RAND()*100)
print 10 different value between
1&100
• declare @count int
• set @count=1
• while (@count<=10)
• begin
• print floor(rand()*100)
• set @count=@count+1
• end
• --round to 2 places after(to the right) decimal ponit
• select ROUND (123.756,2)--returns 123.760
• --Trancate anything after 2 places,after(to the right) decimal point
• select ROUND (123.756,2,1)--return 123.750
• -- round to 1 place after (to right) the decimal point
• select ROUND123.756,1)--123.800
• --truncate anything after 1 place, after(to right)the decimal ponit
• select ROUND(123.756,1,1)--123.700
• --round the last 2 places, before the decimal point
• select ROUND (123.756,-2)--returns 100.000
• --round the last 1 places, before the decimal point
• select ROUND (123.756,-1)--returns 120.000
THANK YOU

You might also like