I'm not sure that you can get what you want. When a error is raised, SQL Server sends the error to the client. You do have the opportunity to get the error number with @@ERROR but the message is already starting to bubble up.
Probably the best you could do is provide a wrapper around the call to SQLEXEC() that captures the error information and converts it to the form that you want.
-Mike
>Hi,
>
>I am excuting a stored procedure of SQL2000 from VFP using SQLEXEC().
>
>This Stored Procedure (lets say usp_1) In turn calls another Stored (lets say usp_2)Procedure to Insert Records into the different Tables in a Database.
>
>sErrorStr = ""
>=SQLEXEC(nHandle,"EXEC usp_1 ?sErrorStr")
>
>Now usp_2 is passing a prameter (OUTPUT) to usp_1, which is the error number generated (if at all) by the insert statements (or 0 if none). I have used the @@ERROR immediately after every insert statements.
>usp_1 accepts this parameter passed by usp_2 and based on some logic passes the necessary output ( which is a string ) to VFP's output parameter
>
>What is happening is whenever there is a error in the usp_2 at the time of insert the whole procedure is terminated and the output of SQLEXEC() is -1.
>
>What i want is that it should return the error code to usp_1, which will then pass the necessary output to VFP's output parameter (sErrorStr).
>
>Please help...
>
>Kind Regards,
>KUMAR.