Because the database engine does not allow me to add try / catch to my porceement

0

I need to add try/catch to the procedure and I get some errors, this is my stored procedure

CREATE PROCEDURE perfilCur
@opcion INT
AS
SET NOCOUNT ON;
 BEGIN TRY

    IF @opcion = 1
    BEGIN
       SELECT TOP 1 (PERFIL) + 1 AS NuevoPerfil FROM Login_Perfiles ORDER BY PERFIL DESC
    END;
    ELSE IF @opcion = 2
    BEGIN
        SELECT * FROM Login_Perfiles    
    END;

 END TRY
 BEGIN CATCH
    THROW;
 END CATCH;

and the errors are these:

  

Msg 170, Level 15, State 1, Procedure profileCur, Line 13 [Batch Start   Line 0] Line 13: Incorrect syntax near 'TRY'. Msg 156, Level 15, State   1, Procedure profileCur, Line 24 [Batch Start Line 0] Incorrect syntax   near the keyword 'END'.

    
asked by Luis Miguel Viana 13.06.2018 в 19:35
source

0 answers