SQL Server SQMETERS Function
Updated 2023-11-08 20:58:47.940000
Description
Use the scalar function SQMETERS to convert from acres, hectares, square feet, square inches, square meters, square miles, or square yards to square meters.
Syntax
SELECT [westclintech].[wct].[SQMETERS] (
<@Area, float,>
,<@From_scale, nvarchar(4000),>
,<@To_scale, nvarchar(4000),>)
Arguments
@Area
is any real number. @Area is an expression of type float or of a type that can be implicitly converted to float.
@From_scale
is the description of the units for @Area. @From_scale must be a valid value as specified in area unit representations. @From_scale must be of a data type that is implicitly convertible to varchar.
@To_scale
is the description of the units for that @Area is to be converted into. @To_scale must be a valid value as specified in area unit representations. In addition to square meters, @To_scale can be square decimeters, square centimeters, square millimeters, square micrometers, square nanometers, square picometers, square femtometers, square attometers, square zeptometers, square yoctometers, square decameters, square hectometers, or square kilometers .@To_scale must be of a data type that is implicitly convertible to varchar.
Return Type
float
Remarks
The following table is a representation of the conversion of one of the area units of measure into square meters:
| column 1 | column 2 |
|---|---|
| acres | 4046.85642 |
| square inches | 0.00064516 |
| square feet | 0.09290304 |
| square yards | 0.83612736 |
| square miles | 2589998.11 |
| square meters | 1 |
| hectares | 10000 |
Conversion of meters includes all the standard prefixes with kilo representing 1,000 and yocto representing 10E-24.
Examples
select wct.SQMETERS(100, 'yd^2', 'm^2');
Here is the result set
----------------------
83.612736