Reviewed by Aditya Kumar · Last reviewed 2026-03-24
**Architectural Logic**: Error handling affects debuggability and caller experience. **TRY-CATCH**: Captures errors in block; enables cleanup or logging. **THROW** (SQL 2012+): Raises error; preserves call stack; use in CATCH to rethrow. **RAISERROR**: Legacy; custom messages;...
Architectural Logic: Error handling affects debuggability and caller experience. TRY-CATCH: Captures errors in block; enables cleanup or logging. THROW (SQL 2012+): Raises error; preserves call stack; use in CATCH to rethrow. RAISERROR: Legacy; custom messages; doesn't preserve stack. Example: BEGIN TRY; INSERT ...; END TRY BEGIN CATCH; THROW; END CATCH. Why THROW: Better diagnostics; RAISERROR is deprecated for new code. Best Practice: Prefer THROW; use TRY-CATCH in procedures; log to error table; don't swallow without logging. Severity levels; avoid exposing internals to callers.
Red Flag: Empty CATCH block that swallows errors—production nightmare. Pro-Move: Log errors; rethrow with THROW; use custom error table for audit; reference severity for different handling.
According to DataEngPrep.tech, this is one of the most frequently asked SQL interview questions, reported at 1 company. DataEngPrep.tech maintains an editor-reviewed database of 1,863 data engineering interview questions across 7 categories.