Writing T-SQL Scripts: Batches and GO, Variables, IF/WHILE, TRY...CATCH, THROW and Transactional Scripts
A safe T-SQL script uses SET XACT_ABORT ON, validation first, a transaction inside TRY...CATCH, and ROLLBACK plus THROW in CATCH; with XACT_ABORT OFF a transaction stays committable after an error and half-done work can become permanent. With real output: SET vs SELECT assignment, GO as a tool command, Msg 208 slipping past CATCH, the ROLLBACK THROW trap and a rerunnable price update in chunks of 20.
15 Nov 2026
·
18 min
·
9