To create a User Defined Function (UDF) that converts volume from Cubic Meters to Cubic Feet, that uses decimal(10,4) data type with precision 10 and scale 4 for input and output volume values, use the following command:
CREATE FUNCTION [dbo].[ufn_cbm2cbft] (@cbm decimal(10,4))
RETURNS decimal(10,4)
AS
BEGIN
RETURN (@cbm * 35.3147)
END
To use this user-defined function (for example to convert 12.7331 cubic meters to cubic feet):
SELECT dbo.ufn_cbm2cbft (12.7331)
To create a User Defined Function (UDF) that converts volume from Cubic Feet to Cubic Meters, that uses decimal(10,4) data type with precision 10 and scale 4 for input and output volume values, use the following command:
CREATE FUNCTION [dbo].[ufn_cbft2cbm] (@cbft decimal(10,4))
RETURNS decimal(10,4)
AS
BEGIN
RETURN (@cbft * 0.0283168)
END
To use this user-defined function (for example to convert 92.7131 cubic feet to cubic meters):
SELECT dbo.ufn_cbft2cbm (92.7131)
Leave a Reply