1. Learn
  2. /
  3. Courses
  4. /
  5. Writing Functions and Stored Procedures in SQL Server

Exercise

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.

Instructions

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