Pradeep Gaur
Pradeep Gaur

Reputation: 573

Why finally block is not given in SQL SERVER?

All language like C#,VB.NET all have try catch finally block but SQL server only have try and catch only why not finally block is given is there any specific reason for that?

Upvotes: 6

Views: 5012

Answers (3)

A-K
A-K

Reputation: 17090

There are many other problems with TRY...CATCH block, such as you cannot rethrow an error exactly as you caught it, so I would use C# error handling for anything complex. I have wrote a whole book chapter on it, you can download a free pdf here

Upvotes: 7

John Sansom
John Sansom

Reputation: 41849

In my opinion TRY/CATCH/FINALLY is very much a procedural programming method and therefore does not really have a place or need to be included within T-SQL, what is considered to be very much a SET based programming language.

As wallyk states and I agree, the existing TRY/CATCH Block in T-SQL caters for the vast majority of requirements.

I wonder if perhaps you are trying to implement complex process logic that would be better housed/managed in the application tier.

Upvotes: 0

wallyk
wallyk

Reputation: 57784

It's because the default error handling is often good enough. It used to be hard to write code which could compile but cause some bad fault.

Upvotes: 0

Related Questions