SQL Server › Error Handling with TRY CATCH
What is the difference between using THROW and RAISERROR to raise a custom error in SQL Server?
IntermediateAnswer
THROW is the newer, simpler way to raise an error, automatically preserving the original error information when used without parameters inside a CATCH block, while RAISERROR is the older approach that offers more formatting options like inserting values into the error message, but requires slightly more code to use correctly and does not automatically stop batch execution the same way THROW does.
BEGIN CATCH
THROW; -- re-throws the original error exactly as it occurred
END CATCH;
-- Custom error message
THROW 50001, 'Insufficient balance for this transaction.', 1;Real-world example A stored procedure re-throws a caught error using THROW after logging it, preserving all the original error details for the calling application while still recording what happened for troubleshooting purposes.