send batch of sql statements to sql server

J

JT

can someone point me in the right direction for learning more about how to
go about sending a batch of sql statements from asp to sql server, and
having errors appropriately handled?

for example,

i want to send the following stored procedure calls to sql server in a
single batch from my asp code, rather than using a loop in asp to execute
each procedure individiually. if one of these fails, they all should fail.

exec myProc @param1 = 'A'
exec myProc @param1 = 'B'
exec myProc @param1 = 'C'
exec myProc @param1 = 'D'
exec myProc @param1 = 'E'
exec myProc @param1 = 'F'

thanks,

JT
 
B

Bob Barrows [MVP]

JT said:
can someone point me in the right direction for learning more about
how to go about sending a batch of sql statements from asp to sql
server, and having errors appropriately handled?

for example,

i want to send the following stored procedure calls to sql server in a
single batch from my asp code, rather than using a loop in asp to
execute each procedure individiually. if one of these fails, they
all should fail.

exec myProc @param1 = 'A'
exec myProc @param1 = 'B'
exec myProc @param1 = 'C'
exec myProc @param1 = 'D'
exec myProc @param1 = 'E'
exec myProc @param1 = 'F'

thanks,

JT


Personally, I would encapsulate these in a stored procedure, using a
transaction:

CREATE PROCEDURE RunProcs (
@param1 char(1),
....,
@param6 char(1)) AS

declare @err int
BEGIN TRANSACTION
exec @err=myproc @param1
if @err <> 0
begin
rollback transaction
return 1
end
exec @err=myproc @param2
if @err <> 0
begin
rollback transaction
return 2
end
....
exec @err=myproc @param6
if @err <> 0
begin
rollback transaction
return 6
end
commit transaction

Bob Barrows
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,482
Members
44,901
Latest member
Noble71S45

Latest Threads

Top