开始使用免费开始使用

使用存储过程进行 INSERT

dbo 架构中创建名为 cusp_RideSummaryCreate 的存储过程,用于向 RideSummary 表插入一条记录。

本练习是课程的一部分

SQL Server 中的函数与存储过程编写

查看课程

练习说明

  • 定义两个输入参数,名称分别为 @DateParm@RideHrsParm
  • @DateParm@RideHrsParm 插入到 RideSummary 表的 DateRideHours 列中。
  • 选择刚插入的那条记录,其 Date 等于 @DateParm

交互式实操练习

通过完成这段示例代码来试试这个练习。

-- 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;
编辑并运行代码