returning data from a Stored Procedure

M

Mitri Dahdaly

Hi all

I hope you can help, I am in the process of converting my access based
application in to an access data project with SQL Server. I begain doing
this a few years ago and then gave up but I am back at it again. When I
originally started I was using Access 2000 with SQL Server 7. I am now using
Access 2003 and SQL Server 2005. I have a situation where I had something
working in the old versions of access and SQL server but are refusing to
work in the current versions. I have created a stored procedure that inserts
some data in access I have the following code:

Dim rst As New ADODB.Recordset
Dim objCommand As New ADODB.Command

objCommand.ActiveConnection = dbs
'Stored Procedure Name
objCommand.CommandText = "Insert_Res"
objCommand.CommandType = adCmdStoredProc
'objCommand.Parameters.Refresh
objCommand.Parameters("@CustomerID") = Me!CustomerID
// More parameters go here

Set rst = objCommand.Execute
Me.ReservationID = rst(0)

The me.reservationid line cause an error 3265 run time error. My stored
procedure looks like this:

USE [LCS_Master_2003SQL]

GO

/****** Object: StoredProcedure [dbo].[Insert_Res] Script Date: 11/25/2007
13:35:47 ******/

SET ANSI_NULLS ON

GO

SET QUOTED_IDENTIFIER ON

GO

ALTER Procedure [dbo].[Insert_Res]

(

-- Declare all Inputs


-- Reservation Details

----------------------------------------------------------------------------------------

@CustomerID varchar(10),

@FirstName varchar(20),

@LastName varchar(30),

@PickupAddress varchar(30),

@PickupSuffix varchar(4),

@PickupCity varchar(30),

@PickupRegion varchar(2),

@PickupPostalCode varchar(15),

@PickupPhone varchar(15),

@PickupZone varchar(10),

@PickupDate datetime,

@PickupIntersection varchar(100),

@DropoffAddress varchar(30),

@DropoffSuffix varchar(4),

@DropoffCity varchar(30),

@DropoffRegion varchar(2),

@DropoffPostalCode varchar(10),

@DropoffPhone varchar(15),

@DropoffZone int,

@DismissDate datetime = '',

@PaymentMethod varchar(10),

@CreditCardNumber varchar(20),

@ExpiryDate varchar(22),

@InputDate datetime,

@LastActivityDate datetime,

@UserID varchar(30),

@Passengers smallint,

@WakeupDate varchar(22),

@ContactFirstName varchar(50),

@ContactName varchar(30),

@ContactPhone varchar(15),

@contactEmail varchar(50),

@emailc bit,

@PurchaseOrder varchar(15),

@Appartment varchar(5),

@Buzzer varchar(5),

@InitialUserID varchar(30),

@Notes varchar(100),

@psemail varchar(50),

@email bit,

@PickupFlight varchar(50),

@PickupAirline varchar(50),

@PickupFlightTime varchar(50),

@DropoffFlight varchar(50),

@DropoffAirline varchar(50),

@DropoffFlightTime varchar(50),

@Ref as varchar(3),

--This will be used for Dynamic SQL to insert records for Dispatch subtable

--@Disp varchar(2000)

--@MXRSID varchar(10)

@VehicleType int

--@HourlyRate varchar(10),

--@UserID varcahr(30),

--@Hours smallint

-----------------------------------------------------------------------------------------


output

)

As

-- Declare all Variables

Declare

@MXRSID varchar(10),

@MXRSIDPRE INTEGER,

@MXRSINT INTEGER,

@varvchrError varchar(100), -- keeps the error message.

--@ResPre varchar(2),

@VT varchar(10),

@ResID int


--SELECT @ResPre = Reference

--FROM MyCompany


SELECT @MXRSID = MAX(ReservationID)

FROM dbo.Reservations

where ReservationID like @Ref + '%'


if @MXRSID is Null

set @MXRSID = @Ref + '000000'


set @MXRSIDPRE = CAST(SUBSTRING(@MXRSID, 3, 6 ) AS INT)

set @MXRSINT = @MXRSIDPRE + 1


if Len(@MXRSINT) < 6

set @MXRSID = @MXRSINT

if Len(@MXRSINT) = 5

set @MXRSID = @Ref + '0' + CAST(@MXRSINT AS VARCHAR(5))

if Len(@MXRSINT) = 4

set @MXRSID = @Ref + '00' + CAST(@MXRSINT AS VARCHAR(4))

if Len(@MXRSINT) = 3

set @MXRSID = @Ref + '000' + CAST(@MXRSINT AS VARCHAR(3))

if Len(@MXRSINT) = 2

set @MXRSID = @Ref + '0000' + CAST(@MXRSINT AS VARCHAR(2))

if Len(@MXRSINT) = 1

set @MXRSID = @Ref + '00000' + CAST(@MXRSINT AS VARCHAR(1))

if Len(@MXRSINT) = 0

set @MXRSID = @Ref + '000000'

begin transaction INS_RES_ID


INSERT INTO dbo.Reservations

(ReservationID,

CustomerID,

FirstName,

LastName,

PickupAddress,

PickupSuffix,

PickupCity,

PickupRegion,

PickupPostalCode,

PickupPhone,

PickupZone,

PickupDate,

PickupIntersection,

DropoffAddress,

DropoffSuffix,

DropoffCity,

DropoffRegion,

DropoffPostalCode,

DropoffPhone,

DropoffZone,

PaymentMethod,

CreditCardNumber,

ExpiryDate,

InputDate,

LastActivityDate,

UserID,

Passengers,

WakeupDate,

ContactName,

ContactPhone,

PurchaseOrder,

Appartment,

Buzzer,

InitialUserID,

Notes,

Passemail,

email,

PickupFlight,

PickupAirline,

PickupFlightTime,

DropoffFlight,

DropoffAirline,

DropoffFlightTime)

Values(@MXRSID,

@CustomerID,

@FirstName,

@LastName,

@PickupAddress,

@PickupSuffix,

@PickupCity,

@PickupRegion,

@PickupPostalCode,

@PickupPhone,

@PickupZone,

@PickupDate,

@PickupIntersection,

@DropoffAddress,

@DropoffSuffix,

@DropoffCity,

@DropoffRegion,

@DropoffPostalCode,

@DropoffPhone,

@DropoffZone,

@PaymentMethod,

@CreditCardNumber,

@ExpiryDate,

@InputDate,

@LastActivityDate,

@UserID,

@Passengers,

@WakeupDate,

@ContactName,

@ContactPhone,

@PurchaseOrder,

@Appartment,

@Buzzer,

@UserID,

@Notes,

@psemail,

@email,

@PickupFlight,

@PickupAirline,

@PickupFlightTime,

@DropoffFlight,

@DropoffAirline,

@DropoffFlightTime)


--select @ResID = ResID from Reservations where ReservationID = @MXRSID

SET @ResID = SCOPE_IDENTITY()


INSERT INTO dbo.Dispatches (ResID, VehicleTypeID, Status)

VALUES(@ResID, @VehicleType, 0)


if @@error <> 0

begin

select @varvchrError = 'Error creating the caution. ' + @MXRSID

goto ErrOut

end


commit transaction INS_RES_ID

--@ResID = @ResID output

--exec @MXRSID

-- select @ResID, @MXRSID

Return @ResID


ErrOut:

rollback transaction

raiserror (50099, 16, 1, @varvchrError, 'Insert_Res')


return
 
S

Sylvain Lafontaine

First, the official newsgroup for ADP is m.p.access.adp.sqlserver; for this
kind of question, you should also go the newsgroup m.p.data.ado as your
question is more strictly about ADO than it is about ADP or form coding.

Second, don't use the keyword New for the dimension of rst if you are
planning to use the Set command on it. For another technical reason, it's
also better to not use it with the objCommand object:

Dim rst As ADODB.Recordset

Dim objCommand As ADODB.Command
Set objCommand = New ADODB.Command

In your case, rst(0) is empty because there is no Select statement in your
SP; so rst is either closed or at EOF. If you want to capture the value of
"Return @ResID"; you must take a look at the first parameter in the
parameters collection of the command object:

MsgBox objCommand.Parameters (0)

or:

Msgbox objCommand.Parameters ("@RETURN_VALUE")

Your line « if Len(@MXRSINT) < 6 set @MXRSID = @MXRSINT » looks suspicious,
maybe it should be « if Len(@MXRSINT) > 6 set @MXRSID = @MXRSINT ». You
could also replace the following lines with:

set @MXRSID = @Ref + Right ('000000' + CAST(@MXRSINT AS VARCHAR(6)), 6)

but I'm not sure as I don't really follow your logic here.

Important: when working with ADP and/or with ADO, you will often find useful
or necessary to add the option SET NOCOUNT ON at the beginning of your SP;
particularly (but not necessarily) for those SP that are designed to be
bound to a form or a control.

Finally, making some cleanup before posting shouldn't hurt you.

--
Sylvain Lafontaine, ing.
MVP - Technologies Virtual-PC
E-mail: sylvain aei ca (fill the blanks, no spam please)


Mitri Dahdaly said:
Hi all

I hope you can help, I am in the process of converting my access based
application in to an access data project with SQL Server. I begain doing
this a few years ago and then gave up but I am back at it again. When I
originally started I was using Access 2000 with SQL Server 7. I am now
using Access 2003 and SQL Server 2005. I have a situation where I had
something working in the old versions of access and SQL server but are
refusing to work in the current versions. I have created a stored
procedure that inserts some data in access I have the following code:

Dim rst As New ADODB.Recordset
Dim objCommand As New ADODB.Command

objCommand.ActiveConnection = dbs
'Stored Procedure Name
objCommand.CommandText = "Insert_Res"
objCommand.CommandType = adCmdStoredProc
'objCommand.Parameters.Refresh
objCommand.Parameters("@CustomerID") = Me!CustomerID
// More parameters go here

Set rst = objCommand.Execute
Me.ReservationID = rst(0)

The me.reservationid line cause an error 3265 run time error. My stored
procedure looks like this:

USE [LCS_Master_2003SQL]

GO

/****** Object: StoredProcedure [dbo].[Insert_Res] Script Date: 11/25/2007
13:35:47 ******/

SET ANSI_NULLS ON

GO

SET QUOTED_IDENTIFIER ON

GO

ALTER Procedure [dbo].[Insert_Res]

(

-- Declare all Inputs


-- Reservation Details

----------------------------------------------------------------------------------------

@CustomerID varchar(10),

@FirstName varchar(20),

@LastName varchar(30),

@PickupAddress varchar(30),

@PickupSuffix varchar(4),

@PickupCity varchar(30),

@PickupRegion varchar(2),

@PickupPostalCode varchar(15),

@PickupPhone varchar(15),

@PickupZone varchar(10),

@PickupDate datetime,

@PickupIntersection varchar(100),

@DropoffAddress varchar(30),

@DropoffSuffix varchar(4),

@DropoffCity varchar(30),

@DropoffRegion varchar(2),

@DropoffPostalCode varchar(10),

@DropoffPhone varchar(15),

@DropoffZone int,

@DismissDate datetime = '',

@PaymentMethod varchar(10),

@CreditCardNumber varchar(20),

@ExpiryDate varchar(22),

@InputDate datetime,

@LastActivityDate datetime,

@UserID varchar(30),

@Passengers smallint,

@WakeupDate varchar(22),

@ContactFirstName varchar(50),

@ContactName varchar(30),

@ContactPhone varchar(15),

@contactEmail varchar(50),

@emailc bit,

@PurchaseOrder varchar(15),

@Appartment varchar(5),

@Buzzer varchar(5),

@InitialUserID varchar(30),

@Notes varchar(100),

@psemail varchar(50),

@email bit,

@PickupFlight varchar(50),

@PickupAirline varchar(50),

@PickupFlightTime varchar(50),

@DropoffFlight varchar(50),

@DropoffAirline varchar(50),

@DropoffFlightTime varchar(50),

@Ref as varchar(3),

--This will be used for Dynamic SQL to insert records for Dispatch
subtable

--@Disp varchar(2000)

--@MXRSID varchar(10)

@VehicleType int

--@HourlyRate varchar(10),

--@UserID varcahr(30),

--@Hours smallint

-----------------------------------------------------------------------------------------


output

)

As

-- Declare all Variables

Declare

@MXRSID varchar(10),

@MXRSIDPRE INTEGER,

@MXRSINT INTEGER,

@varvchrError varchar(100), -- keeps the error message.

--@ResPre varchar(2),

@VT varchar(10),

@ResID int


--SELECT @ResPre = Reference

--FROM MyCompany


SELECT @MXRSID = MAX(ReservationID)

FROM dbo.Reservations

where ReservationID like @Ref + '%'


if @MXRSID is Null

set @MXRSID = @Ref + '000000'


set @MXRSIDPRE = CAST(SUBSTRING(@MXRSID, 3, 6 ) AS INT)

set @MXRSINT = @MXRSIDPRE + 1


if Len(@MXRSINT) < 6

set @MXRSID = @MXRSINT

if Len(@MXRSINT) = 5

set @MXRSID = @Ref + '0' + CAST(@MXRSINT AS VARCHAR(5))

if Len(@MXRSINT) = 4

set @MXRSID = @Ref + '00' + CAST(@MXRSINT AS VARCHAR(4))

if Len(@MXRSINT) = 3

set @MXRSID = @Ref + '000' + CAST(@MXRSINT AS VARCHAR(3))

if Len(@MXRSINT) = 2

set @MXRSID = @Ref + '0000' + CAST(@MXRSINT AS VARCHAR(2))

if Len(@MXRSINT) = 1

set @MXRSID = @Ref + '00000' + CAST(@MXRSINT AS VARCHAR(1))

if Len(@MXRSINT) = 0

set @MXRSID = @Ref + '000000'

begin transaction INS_RES_ID


INSERT INTO dbo.Reservations

(ReservationID,

CustomerID,

FirstName,

LastName,

PickupAddress,

PickupSuffix,

PickupCity,

PickupRegion,

PickupPostalCode,

PickupPhone,

PickupZone,

PickupDate,

PickupIntersection,

DropoffAddress,

DropoffSuffix,

DropoffCity,

DropoffRegion,

DropoffPostalCode,

DropoffPhone,

DropoffZone,

PaymentMethod,

CreditCardNumber,

ExpiryDate,

InputDate,

LastActivityDate,

UserID,

Passengers,

WakeupDate,

ContactName,

ContactPhone,

PurchaseOrder,

Appartment,

Buzzer,

InitialUserID,

Notes,

Passemail,

email,

PickupFlight,

PickupAirline,

PickupFlightTime,

DropoffFlight,

DropoffAirline,

DropoffFlightTime)

Values(@MXRSID,

@CustomerID,

@FirstName,

@LastName,

@PickupAddress,

@PickupSuffix,

@PickupCity,

@PickupRegion,

@PickupPostalCode,

@PickupPhone,

@PickupZone,

@PickupDate,

@PickupIntersection,

@DropoffAddress,

@DropoffSuffix,

@DropoffCity,

@DropoffRegion,

@DropoffPostalCode,

@DropoffPhone,

@DropoffZone,

@PaymentMethod,

@CreditCardNumber,

@ExpiryDate,

@InputDate,

@LastActivityDate,

@UserID,

@Passengers,

@WakeupDate,

@ContactName,

@ContactPhone,

@PurchaseOrder,

@Appartment,

@Buzzer,

@UserID,

@Notes,

@psemail,

@email,

@PickupFlight,

@PickupAirline,

@PickupFlightTime,

@DropoffFlight,

@DropoffAirline,

@DropoffFlightTime)


--select @ResID = ResID from Reservations where ReservationID = @MXRSID

SET @ResID = SCOPE_IDENTITY()


INSERT INTO dbo.Dispatches (ResID, VehicleTypeID, Status)

VALUES(@ResID, @VehicleType, 0)


if @@error <> 0

begin

select @varvchrError = 'Error creating the caution. ' + @MXRSID

goto ErrOut

end


commit transaction INS_RES_ID

--@ResID = @ResID output

--exec @MXRSID

-- select @ResID, @MXRSID

Return @ResID


ErrOut:

rollback transaction

raiserror (50099, 16, 1, @varvchrError, 'Insert_Res')


return
 
M

Mitri Dahdaly

Thanks I got it working as I want and will post to the other group in the
future. I recreated the SP in SQL Server 2005 using the template that is
provided, as I said since this is a conversion there is still alot of work
to be done I will try your advice on the record set and command objects.

Sylvain Lafontaine said:
First, the official newsgroup for ADP is m.p.access.adp.sqlserver; for
this kind of question, you should also go the newsgroup m.p.data.ado as
your question is more strictly about ADO than it is about ADP or form
coding.

Second, don't use the keyword New for the dimension of rst if you are
planning to use the Set command on it. For another technical reason, it's
also better to not use it with the objCommand object:

Dim rst As ADODB.Recordset

Dim objCommand As ADODB.Command
Set objCommand = New ADODB.Command

In your case, rst(0) is empty because there is no Select statement in your
SP; so rst is either closed or at EOF. If you want to capture the value
of "Return @ResID"; you must take a look at the first parameter in the
parameters collection of the command object:

MsgBox objCommand.Parameters (0)

or:

Msgbox objCommand.Parameters ("@RETURN_VALUE")

Your line « if Len(@MXRSINT) < 6 set @MXRSID = @MXRSINT » looks
suspicious, maybe it should be « if Len(@MXRSINT) > 6 set @MXRSID =
@MXRSINT ». You could also replace the following lines with:

set @MXRSID = @Ref + Right ('000000' + CAST(@MXRSINT AS VARCHAR(6)), 6)

but I'm not sure as I don't really follow your logic here.

Important: when working with ADP and/or with ADO, you will often find
useful or necessary to add the option SET NOCOUNT ON at the beginning of
your SP; particularly (but not necessarily) for those SP that are designed
to be bound to a form or a control.

Finally, making some cleanup before posting shouldn't hurt you.

--
Sylvain Lafontaine, ing.
MVP - Technologies Virtual-PC
E-mail: sylvain aei ca (fill the blanks, no spam please)


Mitri Dahdaly said:
Hi all

I hope you can help, I am in the process of converting my access based
application in to an access data project with SQL Server. I begain doing
this a few years ago and then gave up but I am back at it again. When I
originally started I was using Access 2000 with SQL Server 7. I am now
using Access 2003 and SQL Server 2005. I have a situation where I had
something working in the old versions of access and SQL server but are
refusing to work in the current versions. I have created a stored
procedure that inserts some data in access I have the following code:

Dim rst As New ADODB.Recordset
Dim objCommand As New ADODB.Command

objCommand.ActiveConnection = dbs
'Stored Procedure Name
objCommand.CommandText = "Insert_Res"
objCommand.CommandType = adCmdStoredProc
'objCommand.Parameters.Refresh
objCommand.Parameters("@CustomerID") = Me!CustomerID
// More parameters go here

Set rst = objCommand.Execute
Me.ReservationID = rst(0)

The me.reservationid line cause an error 3265 run time error. My stored
procedure looks like this:

USE [LCS_Master_2003SQL]

GO

/****** Object: StoredProcedure [dbo].[Insert_Res] Script Date:
11/25/2007 13:35:47 ******/

SET ANSI_NULLS ON

GO

SET QUOTED_IDENTIFIER ON

GO

ALTER Procedure [dbo].[Insert_Res]

(

-- Declare all Inputs


-- Reservation Details

----------------------------------------------------------------------------------------

@CustomerID varchar(10),

@FirstName varchar(20),

@LastName varchar(30),

@PickupAddress varchar(30),

@PickupSuffix varchar(4),

@PickupCity varchar(30),

@PickupRegion varchar(2),

@PickupPostalCode varchar(15),

@PickupPhone varchar(15),

@PickupZone varchar(10),

@PickupDate datetime,

@PickupIntersection varchar(100),

@DropoffAddress varchar(30),

@DropoffSuffix varchar(4),

@DropoffCity varchar(30),

@DropoffRegion varchar(2),

@DropoffPostalCode varchar(10),

@DropoffPhone varchar(15),

@DropoffZone int,

@DismissDate datetime = '',

@PaymentMethod varchar(10),

@CreditCardNumber varchar(20),

@ExpiryDate varchar(22),

@InputDate datetime,

@LastActivityDate datetime,

@UserID varchar(30),

@Passengers smallint,

@WakeupDate varchar(22),

@ContactFirstName varchar(50),

@ContactName varchar(30),

@ContactPhone varchar(15),

@contactEmail varchar(50),

@emailc bit,

@PurchaseOrder varchar(15),

@Appartment varchar(5),

@Buzzer varchar(5),

@InitialUserID varchar(30),

@Notes varchar(100),

@psemail varchar(50),

@email bit,

@PickupFlight varchar(50),

@PickupAirline varchar(50),

@PickupFlightTime varchar(50),

@DropoffFlight varchar(50),

@DropoffAirline varchar(50),

@DropoffFlightTime varchar(50),

@Ref as varchar(3),

--This will be used for Dynamic SQL to insert records for Dispatch
subtable

--@Disp varchar(2000)

--@MXRSID varchar(10)

@VehicleType int

--@HourlyRate varchar(10),

--@UserID varcahr(30),

--@Hours smallint

-----------------------------------------------------------------------------------------


output

)

As

-- Declare all Variables

Declare

@MXRSID varchar(10),

@MXRSIDPRE INTEGER,

@MXRSINT INTEGER,

@varvchrError varchar(100), -- keeps the error message.

--@ResPre varchar(2),

@VT varchar(10),

@ResID int


--SELECT @ResPre = Reference

--FROM MyCompany


SELECT @MXRSID = MAX(ReservationID)

FROM dbo.Reservations

where ReservationID like @Ref + '%'


if @MXRSID is Null

set @MXRSID = @Ref + '000000'


set @MXRSIDPRE = CAST(SUBSTRING(@MXRSID, 3, 6 ) AS INT)

set @MXRSINT = @MXRSIDPRE + 1


if Len(@MXRSINT) < 6

set @MXRSID = @MXRSINT

if Len(@MXRSINT) = 5

set @MXRSID = @Ref + '0' + CAST(@MXRSINT AS VARCHAR(5))

if Len(@MXRSINT) = 4

set @MXRSID = @Ref + '00' + CAST(@MXRSINT AS VARCHAR(4))

if Len(@MXRSINT) = 3

set @MXRSID = @Ref + '000' + CAST(@MXRSINT AS VARCHAR(3))

if Len(@MXRSINT) = 2

set @MXRSID = @Ref + '0000' + CAST(@MXRSINT AS VARCHAR(2))

if Len(@MXRSINT) = 1

set @MXRSID = @Ref + '00000' + CAST(@MXRSINT AS VARCHAR(1))

if Len(@MXRSINT) = 0

set @MXRSID = @Ref + '000000'

begin transaction INS_RES_ID


INSERT INTO dbo.Reservations

(ReservationID,

CustomerID,

FirstName,

LastName,

PickupAddress,

PickupSuffix,

PickupCity,

PickupRegion,

PickupPostalCode,

PickupPhone,

PickupZone,

PickupDate,

PickupIntersection,

DropoffAddress,

DropoffSuffix,

DropoffCity,

DropoffRegion,

DropoffPostalCode,

DropoffPhone,

DropoffZone,

PaymentMethod,

CreditCardNumber,

ExpiryDate,

InputDate,

LastActivityDate,

UserID,

Passengers,

WakeupDate,

ContactName,

ContactPhone,

PurchaseOrder,

Appartment,

Buzzer,

InitialUserID,

Notes,

Passemail,

email,

PickupFlight,

PickupAirline,

PickupFlightTime,

DropoffFlight,

DropoffAirline,

DropoffFlightTime)

Values(@MXRSID,

@CustomerID,

@FirstName,

@LastName,

@PickupAddress,

@PickupSuffix,

@PickupCity,

@PickupRegion,

@PickupPostalCode,

@PickupPhone,

@PickupZone,

@PickupDate,

@PickupIntersection,

@DropoffAddress,

@DropoffSuffix,

@DropoffCity,

@DropoffRegion,

@DropoffPostalCode,

@DropoffPhone,

@DropoffZone,

@PaymentMethod,

@CreditCardNumber,

@ExpiryDate,

@InputDate,

@LastActivityDate,

@UserID,

@Passengers,

@WakeupDate,

@ContactName,

@ContactPhone,

@PurchaseOrder,

@Appartment,

@Buzzer,

@UserID,

@Notes,

@psemail,

@email,

@PickupFlight,

@PickupAirline,

@PickupFlightTime,

@DropoffFlight,

@DropoffAirline,

@DropoffFlightTime)


--select @ResID = ResID from Reservations where ReservationID = @MXRSID

SET @ResID = SCOPE_IDENTITY()


INSERT INTO dbo.Dispatches (ResID, VehicleTypeID, Status)

VALUES(@ResID, @VehicleType, 0)


if @@error <> 0

begin

select @varvchrError = 'Error creating the caution. ' + @MXRSID

goto ErrOut

end


commit transaction INS_RES_ID

--@ResID = @ResID output

--exec @MXRSID

-- select @ResID, @MXRSID

Return @ResID


ErrOut:

rollback transaction

raiserror (50099, 16, 1, @varvchrError, 'Insert_Res')


return
 
Top