| title | SQUARE (Transact-SQL) | ||
|---|---|---|---|
| description | SQUARE (Transact-SQL) | ||
| author | MikeRayMSFT | ||
| ms.author | mikeray | ||
| ms.reviewer | |||
| ms.date | 03/03/2017 | ||
| ms.prod | sql | ||
| ms.prod_service | synapse-analytics, pdw, sql-database | ||
| ms.technology | t-sql | ||
| ms.topic | reference | ||
| ms.custom | |||
| f1_keywords |
|
||
| helpviewer_keywords |
|
||
| dev_langs |
|
||
| monikerRange | >= aps-pdw-2016 || = azure-sqldw-latest || >= sql-server-2016 || >= sql-server-linux-2017 || = azuresqldb-mi-current |
[!INCLUDE sql-asdb-asdbmi-asa-pdw]
Returns the square of the specified float value.
Transact-SQL Syntax Conventions
SQUARE ( float_expression )
[!INCLUDEsql-server-tsql-previous-offline-documentation]
float_expression
Is an expression of type float or of a type that can be implicitly converted to float.
float
The following example returns the volume of a cylinder having a radius of 1 inch and a height of 5 inches.
DECLARE @h FLOAT, @r FLOAT;
SET @h = 5;
SET @r = 1;
SELECT PI()* SQUARE(@r)* @h AS 'Cyl Vol'; [!INCLUDEssResult]
Cyl Vol
--------------------------
15.707963267948966
The following example returns the square of each value in the volume column in the containers table.
-- Uses AdventureWorks
CREATE TABLE Containers (
ID INT NOT NULL,
Name VARCHAR(20),
Volume FLOAT(24));
INSERT INTO Containers VALUES (1, 'Cylinder', '125.22');
INSERT INTO Containers VALUES (2, 'Cube', '23.98');
SELECT Name, SQUARE(Volume) AS VolSquared
FROM Containers; [!INCLUDEssResult]
Name VolSquared
------------- ----------
Cylinder 15680.05
Cube 575.04