開始使用免費開始

使用 SP 進行 UPDATE

dbo 結構描述中建立一個名為 cuspRideSummaryUpdate 的預存程序,用來更新 RideSummary 資料表中的既有紀錄。

本練習屬於課程

在 SQL Server 中撰寫函式與預存程序

檢視課程

練習說明

  • 這個 SP 應該接受對應每個 RideSummary 欄位的輸入參數,名稱為 @Date@RideHrs
  • @Date 參數設為 date 資料型別,@RideHrs 設為 numeric 資料型別。
  • 使用 UPDATESET 關鍵字,將參數值指定給 RideSummary@DateDate 相符的那筆紀錄。

動手互動練習

試著完成這個範例程式碼,體驗一下這個練習。

-- Create the stored procedure
___ ___ ___.___
	-- Specify @Date input parameter
	(___ ___,
     -- Specify @RideHrs input parameter
     ___ numeric(18,0))
AS
BEGIN
SET NOCOUNT ON
-- Update RideSummary
___ ___
-- Set
___
	___ = @Date,
    ___ = @RideHrs
-- Include records where Date equals @Date
___ ___ = ___
END;
編輯並執行程式碼