Logo

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:

inchesin, inch, inches
feetft, foot, feet
yardsyd, yard, yards
milesmi, mile, miles
nautical milesnmi, nautical mile, nautical miles
furlongsfur, furlong, furlongs
fathomsfath, fathom, fathoms
angstromså, angstrom, angstroms, ångström, ångströms
picaspica, picas, pc
pointspoint, points, pt
kilometerskm, kilometer, kilometers, kilometre, kilometres
hectometershm, hectometer, hectometers, hectometre, hectometres
decametersdam, decameter, decameters, decametre, decametres
metersm, meter, meters, metre, metres
decimetersdm, decimeter, decimeters, decimetre, decimetres
centimeterscm, centimeter, centimeters, centimetre, centimetres
millimetersmm, millimeter, millimeters, millimetre, millimetres
micronsµm, micron, microns,
nanometersnm, nanometer, nanometers, nanometre, nanometres
picometerspm, picometer, picometers, picometre, picometres
femtometersfm, femtometer, femtometers, femtometre, femtometres
attometersam, attometer, attometers, attometre, attometres
zeptometerszm, zeptometer, zeptometers, zeptometre, zeptometres
yoctometersym, yoctometer, yoctometers, yoctometre, yoctometres

Examples

select wct.CONVERTLENGTH(.001, 'in', 'µm');

Here is the result set.

column 1
25.4