LoslegenKostenlos loslegen

CATCH an error

Execute dbo.cuspRideSummaryDelete and pass an invalid @DateParm value of '1/32/2018' to see how the error is handled. The invalid date will be accepted by the nvarchar data type of @DateParm, but the error will occur when SQL attempts to convert it to a valid date when executing the stored procedure.

Diese Übung ist Teil des Kurses

Writing Functions and Stored Procedures in SQL Server

Kurs anzeigen

Anleitung zur Übung

  • DECLARE variable @ReturnCode as an integer and @ErrorOut as a nvarchar(max).
  • Execute dbo.cuspRideSummaryDelete and pass '1/32/2018' as the @DateParm value.
  • Assign @ErrorOut to the @Error parameter.
  • Select both @ReturnCode and @ErrorOut to see their values.

Interaktive Übung

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

-- Create @ReturnCode
___ ___ ___
-- Create @ErrorOut
___ ___ ___(___)
-- Execute the SP, storing the result in @ReturnCode
___ ___ = ___.___
    -- Specify @DateParm
	___ = '1/32/2018',
    -- Assign @ErrorOut to @Error
	___ = ___ OUTPUT
-- Select @ReturnCode and @ErrorOut
___
	___ AS ReturnCode,
    ___ AS ErrorMessage;
Code bearbeiten und ausführen