Hi Friends..
I want to know, How to use of try & Catch block in stored procedure ?
Please explain with example ?
Thanks...
Try & Catch In Stored Procedure
1 Answer
Know the answer? Post it. Somebody with the same question will find it here.
Know the answer? Post it. Somebody with the same question will find it here.
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questions
DevSocialUpcoming · 3rd editionAI Agents ConferenceDec 1–3, 2026Live onlineFree to attend5days leftRegister
Hemant KumarRank #1,202 · 1.5K reputationPosted Dec 11, 2011, 1:56 AM EST
BEGIN TRY BEGIN TRANSACTION -- Start the transaction -- DO your worklike INSERT, UPDATE, DELETE -- If we reach here, success! COMMIT -- commit the transaction END TRY BEGIN CATCH -- Whoops, there was an error IF @@TRANCOUNT > 0 ROLLBACK END CATCHFor more details, you can visit http://www.4guysfromrolla.com/webtech/041906-1.shtml