Open In App

SQUARE() Function in SQL Server

Last Updated : 28 Dec, 2020
Improve
Improve
Like Article
Like
Save
Share
Report

SQUARE() function :
This function in SQL Server is used to return the square of a specified number. For example, if the specified number is 9, this function will return 81 as output.

Features :

  • This function is used to square a given number.
  • This function accepts both that is positive and negative numbers.
  • This function also accepts fraction numbers.
  • This function always returns positive number.
  • This function use the formula “(a)2 = Returned value”, where a is the specified number.

Syntax :

SQUARE(number)

Parameter :
This method accepts a parameter as given below as follows.

  • number –
    Specified number whose square is going to be returned.

Returns :
It returns the square of a specified number.

Example-1 :
Getting the result 16.0 which is the square of the specified number 4.

SELECT SQUARE(4);

Output :

16.0

Example-2 :
Getting the result 4.0 which is the square of the specified negative number -2.

SELECT SQUARE(-2);

Output :

4.0

Example-3 :
Getting the result 0.0 which is the square of the specified number zero (0).

SELECT SQUARE(0);

Output :

0.0

Example-4 :
Getting the result 1.0 which is the square of the specified number 1.

SELECT SQUARE(1);

Output :

1.0

Example-5 :
Getting the result 1.4399999999999999 which is the square of the specified number 1.2.

SELECT SQUARE(1.2);

Output :

1.4399999999999999

Application :
This function is used to return the square of a specified number.


Like Article
Suggest improvement
Previous
Next
Share your thoughts in the comments

Similar Reads