Welcome to dbFreaks.com!
FAQFAQ    SearchSearch      ProfileProfile    Private MessagesPrivate Messages   Log inLog in

Rollback whole transaction save/keep error message/error s..

 
   Database Help (Home) -> Programming RSS
Next:  How to open sql file on same connection?  
Author Message
Bob

External


Since: Feb 07, 2007
Posts: 6



(Msg. 1) Posted: Thu Feb 08, 2007 10:38 pm
Post subject: Rollback whole transaction save/keep error message/error severity information
Archived from groups: microsoft>public>sqlserver>programming (more info?)

Hi all,

In SQL 2005, is it possible to rollback the entire transaction but
save/keep the system generated error message/error severity
information some where? I tried to store the error message in local
memory but once rollback I lost it.

Any ideas would be highly appreciated.

Thanks.

 >> Stay informed about: Rollback whole transaction save/keep error message/error s.. 
Back to top
Login to vote
Adi

External


Since: Mar 05, 2007
Posts: 51



(Msg. 2) Posted: Thu Feb 08, 2007 11:18 pm
Post subject: Re: Rollback whole transaction save/keep error message/error severity information [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

On Feb 9, 8:38 am, "Bob" wrote:
> Hi all,
>
> In SQL 2005, is it possible to rollback the entire transaction but
> save/keep the system generated error message/error severity
> information some where? I tried to store the error message in local
> memory but once rollback I lost it.
>
> Any ideas would be highly appreciated.
>
> Thanks.

I don't understand what you mean when you write that you tried to
store the error information in memory but after rollback the
information is gone. If you rollback a transaction it does not
effect variables (including table variables) at all.

SQL Server 2005 introduced new error handling functions that we can
use in order to get information about run time errors that occurred
during the code's run time. Using the try catch block it is very easy
to rollback the transaction and then store the information about the
error in a logging table. I suggest that you'll have a look in BOL
for explanation and example of the new try catch blocks (it also
includes explanation and example of 6 new error handling functions
that give you plenty of information about the error).

Adi

 >> Stay informed about: Rollback whole transaction save/keep error message/error s.. 
Back to top
Login to vote
xyb

External


Since: Mar 06, 2007
Posts: 11



(Msg. 3) Posted: Thu Feb 08, 2007 11:28 pm
Post subject: Re: Rollback whole transaction save/keep error message/error severity information [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

declare @localv int
begin tran
select top 10 * from articles
raiserror('error raised here',16,1)
select @localv = @@error
rollback tran
print @localv
On 2月9日, 下午2时38分, "Bob" wrote:
> Hi all,
>
> In SQL 2005, is it possible to rollback the entire transaction but
> save/keep the system generated error message/error severity
> information some where? I tried to store the error message in local
> memory but once rollback I lost it.
>
> Any ideas would be highly appreciated.
>
> Thanks.
 >> Stay informed about: Rollback whole transaction save/keep error message/error s.. 
Back to top
Login to vote
Display posts from previous:   
Related Topics:
SQL 2005 Rollback transaction but commit error message - Hi all SQL 2005 gurus, I have an interesting question: In a loop process, is it possible to rollback one transaction if an error occured, but save the error message for this particular instance in a data table (or any where else)? Here is my scenrior: ...

Error: The ROLLBACK TRANSACTION request has no correspondi.. - Hi All, I keep getting the following error messages when the Stored procedure is executed below? Nonqualified transactions are being rolled back. Estimated rollback completion: 100%. 0 Server: Msg 3903, Level 16, State 1, Line 202 The ROLLBACK..

Rollback/transaction/error handling - Hi all, I'm primarily a middle-tier coder who's also administrating the database. I'm not writing any rollback/transaction/error handling code in my sp's. Should I? What are the advantages of inserting this code? What are the dangers of disregarding..

Rollback/transaction/error handling code - Hi all, I'm primarily a middle-tier coder who's also administrating the database. I'm not writing any rollback/transaction/error handling code in my sp's. Should I? What are the advantages of inserting this code? What are the dangers of disregarding..

Transaction Does Not Rollback On Failure - Hi, I'm trying to do a multiple INSERT, but I need it to rollback if any of the records fail to be inserted. I've used Transactions for this before in this manner: BEGIN TRANSACTION; INSERT INTO TABLE (col1,col2) VALUES (1,2) INSERT INTO TABLE..
   Database Help (Home) -> Programming All times are: Pacific Time (US & Canada)
Page 1 of 1

 
You can post new topics in this forum
You can reply to topics in this forum
You can edit your posts in this forum
You can delete your posts in this forum
You can vote in polls in this forum



[ Contact us | Terms of Service/Privacy Policy ]