Get startedGet started for free

CREATE FUNCTIONs

Create three functions to help solve the business case:

  1. Convert distance from miles to kilometers.
  2. Convert currency based on exchange rate parameter.
    (These two functions should return a numeric value with precision of 18 and 2 decimal places.)
  3. Identify the driver shift based on the hour parameter value passed.

This exercise is part of the course

Writing Functions and Stored Procedures in SQL Server

View Course

Hands-on interactive exercise

Have a go at this exercise by completing this sample code.

-- Create the function
___ ___ dbo.ConvertMileToKm (___ numeric(18,2))
-- Specify return data type
___ numeric(18,2)
AS
BEGIN
RETURN
	-- Convert Miles to Kilometers
	(___ ___ * 1.609)
END;
Edit and Run Code