Catching multiple exceptions on the client is robust and easy

Posted by Alexander Kuznetsov on SQL Blog See other posts from SQL Blog or by Alexander Kuznetsov
Published on Wed, 06 Jun 2012 17:30:00 GMT Indexed on 2012/06/06 22:45 UTC
Read the original article Hit count: 418

Maria Zakourdaev has just demonstrated that if our T-SQL throws multiple exceptions, ERROR_MESSAGE() in TRY..CATCH block will only expose one. When we handle errors in C#, we have a very easy access to all errors. The following procedure throws two exceptions: CREATE PROCEDURE dbo.ThrowsTwoExceptions AS BEGIN ; RAISERROR ( 'Error 1' , 16 , 1 ) ; RAISERROR ( 'Error 2' , 16 , 1 ) ; END ; GO EXEC dbo.ThrowsTwoExceptions ; Both exceptions are shown by SSMS: Msg 50000 , LEVEL 16 , State 1 , PROCEDURE...(read more)

© SQL Blog or respective owner

Related posts about error handling

Related posts about Transact SQL