rstacruz / cheatsheets

Cheatsheets for web development - devhints.io
https://devhints.io
13.72k stars 3.59k forks source link

Cheatsheet request: SQL SERVER TRANSACTION WITH ROLLBACK #314

Open desertmark opened 6 years ago

desertmark commented 6 years ago

Hey can you add this one?

begin tran tranName begin try select 'SQL COMMANDS TO EXECUTE' commit tran tranName end try begin catch if (XACT_STATE()=-1) begin print 'transaction fail' rollback tran tranName end end catch;

chadwithuhc commented 5 years ago

This would be great for a PR!