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
 General SQL Server Forums
 New to SQL Server Programming
 Error Handling

Author  Topic 

sent_sara
Constraint Violating Yak Guru

377 Posts

Posted - 2008-06-04 : 01:12:24
Can i any one help regd error handling while executing stored procedure.

Sample Sequence of execution :

CREATE procedure RBI_Control_sp
as
begin
set nocount on

begin try
BEGIN TRANSACTION
--Truncating the Table in ramcovm392(fin_ods)
exec fin_ods..trun_sp

--Data Transfer From the Live Server to Dw-Server
exec fin_ods..RBI_Data_Transfer_sp

insert into fin_wh..Status_report([object_name],row,[date])
select 'Data Tranfer','SUCCESS',getdate()

COMMIT TRANSACTION
end try

begin catch
<b> [i need to insert the type of error in status report table]</b>
rollback transaction
insert into fin_wh..Status_report([object_name],row,[date])
select 'Data Tranfer','FAILURE',getdate()
end catch

set nocount off
end





sachinsamuel
Constraint Violating Yak Guru

383 Posts

Posted - 2008-06-04 : 05:16:09
Below are the functions which you can use get the error details.

ERROR_NUMBER()
ERROR_SEVERITY()
ERROR_STATE()
ERROR_PROCEDURE()
ERROR_LINE()
ERROR_MESSAGE()

Please check the below URL for more information.

http://www.sqlservercentral.com/articles/News/exceptionhandlinginsqlserver2005/2237/

regards
Sachin


Don't sit back because of failure. It will come back to check if you still available. -- Binu
Go to Top of Page

sent_sara
Constraint Violating Yak Guru

377 Posts

Posted - 2008-06-05 : 01:37:44
Txs sachinsamuel.i got it.

quote:
Originally posted by sachinsamuel

Below are the functions which you can use get the error details.

ERROR_NUMBER()
ERROR_SEVERITY()
ERROR_STATE()
ERROR_PROCEDURE()
ERROR_LINE()
ERROR_MESSAGE()

Please check the below URL for more information.

http://www.sqlservercentral.com/articles/News/exceptionhandlinginsqlserver2005/2237/

regards
Sachin


Don't sit back because of failure. It will come back to check if you still available. -- Binu

Go to Top of Page
   

- Advertisement -