Raiserror not worked

Lora 200 Reputation points
2024-01-30T08:56:33.8966667+00:00

Why the raiserror not worked within begin try? Here is the code:

BEGIN TRY
    --Check 
    RAISERROR ('Error! Please retry', 10, 2)
    --If no errors 
    PRINT 'Successful'
END TRY
SQL Server
SQL Server
A family of Microsoft relational database management and analysis systems for e-commerce, line-of-business, and data warehousing solutions.
12,234 questions
{count} votes

1 additional answer

Sort by: Most helpful
  1. Erland Sommarskog 98,751 Reputation points
    2024-01-30T22:30:30.02+00:00

    You have specified the severity as 10, which only generates an informational messages (and for some reason results in severity level 0, which is the same as PRINT.)

    Specify the severity level as 16, which is the highest level for user errors.

    0 comments No comments