SQUARE (Transact-SQL)SQUARE (Transact-SQL)
適用対象:Applies to: SQL ServerSQL Server (サポートされているすべてのバージョン)
SQL ServerSQL Server (all supported versions)
Azure SQL データベースAzure SQL Database
Azure SQL データベースAzure SQL Database
Azure SQL Managed InstanceAzure SQL Managed Instance
Azure SQL Managed InstanceAzure SQL Managed Instance
Azure Synapse AnalyticsAzure Synapse Analytics
Azure Synapse AnalyticsAzure Synapse Analytics
Parallel Data WarehouseParallel Data Warehouse
Parallel Data WarehouseParallel Data Warehouse
SQL ServerSQL Server (サポートされているすべてのバージョン)
SQL ServerSQL Server (all supported versions)
Azure SQL データベースAzure SQL Database
Azure SQL データベースAzure SQL Database
Azure SQL Managed InstanceAzure SQL Managed Instance
Azure SQL Managed InstanceAzure SQL Managed Instance
Azure Synapse AnalyticsAzure Synapse Analytics
Azure Synapse AnalyticsAzure Synapse Analytics
Parallel Data WarehouseParallel Data Warehouse
Parallel Data WarehouseParallel Data Warehouse
指定した浮動小数点値の 2 乗を返します。Returns the square of the specified float value.
Transact-SQL 構文表記規則
Transact-SQL Syntax Conventions
構文Syntax
SQUARE ( float_expression )
注意
SQL Server 2014 以前の Transact-SQL 構文を確認するには、以前のバージョンのドキュメントを参照してください。To view Transact-SQL syntax for SQL Server 2014 and earlier, see Previous versions documentation.
引数Arguments
float_expressionfloat_expression
float 型、または暗黙的に float 型に変換できる 式を指定します。Is an expression of type float or of a type that can be implicitly converted to float.
戻り値の型Return Types
floatfloat
例Examples
次の例では、半径が 1
インチで高さが 5
インチの円柱の体積を返します。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 is the result set.
Cyl Vol
--------------------------
15.707963267948966
例: Azure Synapse AnalyticsAzure Synapse Analytics、Parallel Data WarehouseParallel Data WarehouseExamples: Azure Synapse AnalyticsAzure Synapse Analytics and Parallel Data WarehouseParallel Data Warehouse
次の例では、volume
テーブル内の containers
列の値の 2 乗を返します。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 is the result set.
Name VolSquared
------------- ----------
Cylinder 15680.05
Cube 575.04