Note
Access to this page requires authorization. You can try signing in or .
Access to this page requires authorization. You can try .
SQUARE (Transact-SQL)
Applies to: 👁 Image
SQL Server 👁 Image
Azure SQL Database 👁 Image
Azure SQL Managed Instance 👁 Image
Azure Synapse Analytics 👁 Image
Analytics Platform System (PDW) 👁 Image
SQL analytics endpoint in Microsoft Fabric 👁 Image
Warehouse in Microsoft Fabric
Returns the square of the specified float value.
👁 Image
Transact-SQL syntax conventions
Syntax
SQUARE ( float_expression )
Arguments
float_expression
Is an expression of type float or of a type that can be implicitly converted to float.
Return Types
float
Examples
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';
Here's the result set.
Cyl Vol
--------------------------
15.707963267948966
Examples: Azure Synapse Analytics and Analytics Platform System (PDW)
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;
Here's the result set.
Name VolSquared
------------- ----------
Cylinder 15680.05
Cube 575.04
See Also
Feedback
Was this page helpful?
