>I also don't see any point in the try catch in the calling script of the stored procedure, but the instructor wants it as well as the earliest invoice dates first. The ORDER BY clause though is causing me a problem.
>
>Here's the error message, which I received while trying to save the ALTERING of the STORED PROCEDURE:
>
>
>Msg 1033, Level 15, State 1, Procedure spDateRange, Line 35
>The ORDER BY clause is invalid in views, inline functions, derived tables, subqueries, and common table expressions, unless TOP or FOR XML is also specified.
>Msg 102, Level 15, State 1, Procedure spDateRange, Line 37
>Incorrect syntax near ')'.
>
If you're using
IF NOT EXISTS (select ...)
then, as I said, get rid of the ORDER BY.
Otherwise, can you show the exact piece of code which is failing?
If it's not broken, fix it until it is.
My Blog