As a developer, error handling and try/catch is a very important part of the code I write.
However, in SQL Server Stored Procs, is it best practise to write error handling within the SP? And if one does not (which seems to be the common case), does the exception propagate to the .NET code? I ask that question as I am under the impression that T-SQL behaves like C# error handling.
And what is the best way to write error handling in T-SQL?
Yes, use
TRY...CATCHin your TSQL code. The exception does NOT propogate up to the client in this case.Propogation will occur whenever you use
RAISEERRORor on unhandled SQL exceptions.