Paarthy
2010-05-22 15:39:48 UTC
I recieve a strange error from sql server ,
Msg 0, Level 11, State 0, Line 0
A severe error occurred on the current command. The results, if any,
should be discarded.
when we use a return statement in the stored procedure.
Below the stored procedure:
create procedure sp_test
(
@a as int
)
as
begin
begin try
begin transaction
declare @b as int
set @b = 1
if @a = @b
begin
select 'i am rolling back'
rollback tran
return 1
end
end try
begin catch
if @@trancount >1
begin
rollback tran
end
end catch
end
----------------------------------------------------------------------------------------------------------
when the stored procedure is executed in the below way,
exec sp_test 1
-----------------------------------------------------------------------------------------------------------
But we get error, when we execute in the following way...
can any one please help?
begin tran
exec sp_test 1
rollback tran
Kindest Regards,
Paarthasarathy
paarthasarathyk.blogspot.com
Msg 0, Level 11, State 0, Line 0
A severe error occurred on the current command. The results, if any,
should be discarded.
when we use a return statement in the stored procedure.
Below the stored procedure:
create procedure sp_test
(
@a as int
)
as
begin
begin try
begin transaction
declare @b as int
set @b = 1
if @a = @b
begin
select 'i am rolling back'
rollback tran
return 1
end
end try
begin catch
if @@trancount >1
begin
rollback tran
end
end catch
end
----------------------------------------------------------------------------------------------------------
when the stored procedure is executed in the below way,
exec sp_test 1
-----------------------------------------------------------------------------------------------------------
But we get error, when we execute in the following way...
can any one please help?
begin tran
exec sp_test 1
rollback tran
Kindest Regards,
Paarthasarathy
paarthasarathyk.blogspot.com