Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Know if a stored proc has failed 1

Status
Not open for further replies.

micang

Technical User
Aug 9, 2006
626
US
SQL 2008

Hi All,

I am calling a SQL stored procedure (from a Access db), is there a way in the SQL database to know if the stored procedure has executed successfully?

Any info appreciated.

Michael

 
Hi markos,

Thank you for the reply.

I am using SQL 2008 and Access 2007

For now I have a simple testing procedure that I am calling from Access:

Code:
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
ALTER procedure [dbo].[zzz_test]

@test1 VARCHAR(255), 
@test2 VARCHAR(255)
as


update dbo.Test_customer
set first_name = 'Jim'
where city = @test1 and country = @test2

What I am trying to figure out is when I call it from Access, is there a way know if the procedure has executed successfully?

Many thanks

Michael
 
I'm not sure how to call SQL SPs from Access - haven't worked with Access for long time.

Anyway, you may add to your SP
Code:
declare @ErrorCode int, @RowCount int

Update  ...

select @RowCount = @@ROWCOUNT, @ErrorCode = @@ERROR

if @ErrorCode <> 0
  Raserror('Error %d has occurred', 16, 1, @ErrorCode)

else
  if @RowCount = 0
    Raiserror('No records were updated for %s',16,1,@Test1)

return @ErrorCode

See also
 
Excellent, thanks marko, I can make use of that.

Many thanks for your time.

Michael
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top