Get startedGet started for free

Use SP to INSERT

Create a stored procedure named cusp_RideSummaryCreate in the dbo schema that will insert a record into the RideSummary table.

This exercise is part of the course

Writing Functions and Stored Procedures in SQL Server

View Course

Exercise instructions

  • Define two input parameters named @DateParm and @RideHrsParm.
  • Insert @DateParm and @RideHrsParm into the Date and RideHours columns of the RideSummary table.
  • Select the record that was just inserted where the Date is equal to @DateParm.

Hands-on interactive exercise

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

-- Create the stored procedure
CREATE PROCEDURE dbo.cusp_RideSummaryCreate 
    (___ date, ___ numeric)
AS
BEGIN
SET NOCOUNT ON
-- Insert into the Date and RideHours columns
INSERT ___ dbo.___(___, ___)
-- Use values of @DateParm and @RideHrsParm
___(___, ___) 

-- Select the record that was just inserted
___
    -- Select Date column
	___,
    -- Select RideHours column
    ___
FROM dbo.RideSummary
-- Check whether Date equals @DateParm
WHERE Date = @DateParm
END;
Edit and Run Code