Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2005 Forums
 Transact-SQL (2005)
 supress system error message

Author  Topic 

rajkumarrai_bis
Yak Posting Veteran

78 Posts

Posted - 2007-01-25 : 20:30:25
I Am not able to suppress system generated error message thru
error handling code in SQL Server 2000
Code is Following
begin transaction
select 1/0
if @@error<>0
begin
rollback;print 'rollback'
end
else
begin
commit; print 'Commited'
end

Error is Following
Server: Msg 8134, Level 16, State 1, Line 2
Divide by zero error encountered.
rollback

we want to print only rollback and supress system error message
Is there any way to do this..
This is urgent
Plz help

Michael Valentine Jones
Yak DBA Kernel (pronounced Colonel)

7020 Posts

Posted - 2007-01-25 : 20:35:53
Why is this urgent?



CODO ERGO SUM
Go to Top of Page

PurpleSun
Yak Posting Veteran

50 Posts

Posted - 2007-01-26 : 16:11:48
This error comes from sysmessages table of the Master database. It has severity of 16 and if i remember correctly errors with severity of 11 or higher cannot be suppressed. Of course you can try to remove the record with this error from sysmessages table of the Master database, but i don't think it's a good idea.


quote:
Originally posted by rajkumarrai_bis

I Am not able to suppress system generated error message thru
error handling code in SQL Server 2000
Code is Following
begin transaction
select 1/0
if @@error<>0
begin
rollback;print 'rollback'
end
else
begin
commit; print 'Commited'
end

Error is Following
Server: Msg 8134, Level 16, State 1, Line 2
Divide by zero error encountered.
rollback

we want to print only rollback and supress system error message
Is there any way to do this..
This is urgent
Plz help

Go to Top of Page

Kristen
Test

22859 Posts

Posted - 2007-01-27 : 03:42:23
We check for divide by zero on the code, rather than let SQL have to catch the error, and handle appropriately.

SQL2005 may be able to CATCH the error more gracefully, but I haven't tried it.

Kristen
Go to Top of Page
   

- Advertisement -