SQL Server SQUARE() Function



Definition and Usage

The SQUARE() function in SQL Server calculates the square of a given number. In mathematical terms, it multiplies the number by itself (number * number).

Syntax

Syntax

SQUARE(number)
            

Parameter Values

Parameter Description
number Required. A numeric value. The function will typically handle positive and negative numbers correctly, returning a positive result.

Examples

Example 1: Squaring the Number 64

This example calculates the square of 64.

SQL Query

SELECT SQUARE(64);
            
Output

-----------
4096
            

Example 2: Squaring the Number 13

This example calculates the square of 13.

SQL Query

SELECT SQUARE(13);
            
Output

-----------
169
            

Technical Details

The SQUARE() function is available in SQL Server 2008 and later, Azure SQL Data Warehouse, and Parallel Data Warehouse.