SQL Server CONVERTLENGTH Function
Updated 2024-02-13 19:18:03.887000
Description
Use the scalar function CONVERTLENGTH to convert to and from fathoms, feet, furlongs, inches, meters, miles, nautical miles, pica, points or yards.
Syntax
SELECT [westclintech].[wct].[CONVERTLENGTH] (
<@Length, float,>
,<@From_scale, nvarchar(4000),>
,<@To_scale, nvarchar(4000),>);
Arguments
@Length
is any real number. @Length 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 @Length is being converted from. @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 @Length is being converted to. @To_scale must be a valid value as specified in area unit representations. @To_scale must be of a data type that is implicitly convertible to varchar.
Return Type
float
Remarks
Length unit representations:
| inches | in, inch, inches |
|---|---|
| feet | ft, foot, feet |
| yards | yd, yard, yards |
| miles | mi, mile, miles |
| nautical miles | nmi, nautical mile, nautical miles |
| furlongs | fur, furlong, furlongs |
| fathoms | fath, fathom, fathoms |
| angstroms | å, angstrom, angstroms, ångström, ångströms |
| picas | pica, picas, pc |
| points | point, points, pt |
| kilometers | km, kilometer, kilometers, kilometre, kilometres |
| hectometers | hm, hectometer, hectometers, hectometre, hectometres |
| decameters | dam, decameter, decameters, decametre, decametres |
| meters | m, meter, meters, metre, metres |
| decimeters | dm, decimeter, decimeters, decimetre, decimetres |
| centimeters | cm, centimeter, centimeters, centimetre, centimetres |
| millimeters | mm, millimeter, millimeters, millimetre, millimetres |
| microns | µm, micron, microns, |
| nanometers | nm, nanometer, nanometers, nanometre, nanometres |
| picometers | pm, picometer, picometers, picometre, picometres |
| femtometers | fm, femtometer, femtometers, femtometre, femtometres |
| attometers | am, attometer, attometers, attometre, attometres |
| zeptometers | zm, zeptometer, zeptometers, zeptometre, zeptometres |
| yoctometers | ym, yoctometer, yoctometers, yoctometre, yoctometres |
Examples
select wct.CONVERTLENGTH(.001, 'in', 'µm');
Here is the result set.
| column 1 |
|---|
| 25.4 |