LoslegenKostenlos loslegen

Use SP to INSERT

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

Diese Übung ist Teil des Kurses

Writing Functions and Stored Procedures in SQL Server

Kurs anzeigen

Anleitung zur Übung

  • 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.

Interaktive Übung

Versuche dich an dieser Übung, indem du diesen Beispielcode vervollständigst.

-- 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;
Code bearbeiten und ausführen