I want to know that can we use concept of exception handling in SQL server. If yes then how ?
Thank you.
Exception Handling in SQL Server
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
Jignesh TrivediRank #16 · 50.3K reputationPosted Aug 27, 2012, 4:01 AM EDT
Yes you can use try catch block in SQL server for exception handling.
BEGIN TRY
-- sql sTATEMENT
END TRY
BEGIN CATCH
SELECT
ERROR_NUMBER() as ErrorNumber,
ERROR_MESSAGE() as ErrorMessage;
END CATCH
Please refer...
http://msdn.microsoft.com/en-us/library/ms175976%28v=sql.90%29.aspx
http://blog.sqlauthority.com/2007/04/11/sql-server-2005-explanation-of-trycatch-and-error-handling/