PC Review


Reply
Thread Tools Rating: Thread Rating: 1 votes, 1.00 average.

Executing multiple stored procedures in a single batch

 
 
Venkatesh
Guest
Posts: n/a
 
      26th Aug 2003
Hi

I want to execute multiple SQL Server stored procedures in
a single batch via ADO so that I can minimize network
trips. I need to pass in an array of caommandtype and
commandtext objects. What is the best way to do this. Is
there an example anywhere on how to do this ?

Thanks,

Venkatesh
 
Reply With Quote
 
 
 
 
William \(Bill\) Vaughn
Guest
Posts: n/a
 
      26th Aug 2003
Stored procedures can call stored procedures.
You can also submit a script that contains several SP calls (or other TSQL
code) and deal with the resultsets one-at-a-time. Simply construct a long
string containing the TSQL and use ExecuteNonQuery or Fill to execute it.

--
____________________________________
Bill Vaughn
MVP, hRD
www.betav.com
Please reply only to the newsgroup so that others can benefit.
This posting is provided "AS IS" with no warranties, and confers no rights.
__________________________________

"Venkatesh" <(E-Mail Removed)> wrote in message
news:07b501c36be7$6a0b9ff0$(E-Mail Removed)...
> Hi
>
> I want to execute multiple SQL Server stored procedures in
> a single batch via ADO so that I can minimize network
> trips. I need to pass in an array of caommandtype and
> commandtext objects. What is the best way to do this. Is
> there an example anywhere on how to do this ?
>
> Thanks,
>
> Venkatesh



 
Reply With Quote
 
Venkatesh
Guest
Posts: n/a
 
      27th Aug 2003
I will need to execute several parametrized stored
procedures individually. What I am looking for is a method
by which I can fill a collection of commandtext,command
type and parameter objects , construct a string and call
all the stored procedures at once without having to make
multiple round trips to the server.


>-----Original Message-----
>Stored procedures can call stored procedures.
>You can also submit a script that contains several SP

calls (or other TSQL
>code) and deal with the resultsets one-at-a-time. Simply

construct a long
>string containing the TSQL and use ExecuteNonQuery or

Fill to execute it.
>
>--
>____________________________________
>Bill Vaughn
>MVP, hRD
>www.betav.com
>Please reply only to the newsgroup so that others can

benefit.
>This posting is provided "AS IS" with no warranties, and

confers no rights.
>__________________________________
>
>"Venkatesh" <(E-Mail Removed)> wrote in message
>news:07b501c36be7$6a0b9ff0$(E-Mail Removed)...
>> Hi
>>
>> I want to execute multiple SQL Server stored procedures

in
>> a single batch via ADO so that I can minimize network
>> trips. I need to pass in an array of caommandtype and
>> commandtext objects. What is the best way to do this. Is
>> there an example anywhere on how to do this ?
>>
>> Thanks,
>>
>> Venkatesh

>
>
>.
>

 
Reply With Quote
 
William \(Bill\) Vaughn
Guest
Posts: n/a
 
      27th Aug 2003
CommandText = "SPfirst p1,p2,p3 EXEC SPNext p1, p2 EXEC SPlast p1 "

--
____________________________________
Bill Vaughn
MVP, hRD
www.betav.com
Please reply only to the newsgroup so that others can benefit.
This posting is provided "AS IS" with no warranties, and confers no rights.
__________________________________

"Venkatesh" <(E-Mail Removed)> wrote in message
news:0dc601c36ca1$c946a310$(E-Mail Removed)...
> I will need to execute several parametrized stored
> procedures individually. What I am looking for is a method
> by which I can fill a collection of commandtext,command
> type and parameter objects , construct a string and call
> all the stored procedures at once without having to make
> multiple round trips to the server.
>
>
> >-----Original Message-----
> >Stored procedures can call stored procedures.
> >You can also submit a script that contains several SP

> calls (or other TSQL
> >code) and deal with the resultsets one-at-a-time. Simply

> construct a long
> >string containing the TSQL and use ExecuteNonQuery or

> Fill to execute it.
> >
> >--
> >____________________________________
> >Bill Vaughn
> >MVP, hRD
> >www.betav.com
> >Please reply only to the newsgroup so that others can

> benefit.
> >This posting is provided "AS IS" with no warranties, and

> confers no rights.
> >__________________________________
> >
> >"Venkatesh" <(E-Mail Removed)> wrote in message
> >news:07b501c36be7$6a0b9ff0$(E-Mail Removed)...
> >> Hi
> >>
> >> I want to execute multiple SQL Server stored procedures

> in
> >> a single batch via ADO so that I can minimize network
> >> trips. I need to pass in an array of caommandtype and
> >> commandtext objects. What is the best way to do this. Is
> >> there an example anywhere on how to do this ?
> >>
> >> Thanks,
> >>
> >> Venkatesh

> >
> >
> >.
> >



 
Reply With Quote
 
Venkatesh
Guest
Posts: n/a
 
      27th Aug 2003
Thanks Bill. How do I implement the commandtext and
command parameters collections ? In other worrds, how do I
associate the parameters with the relevant stored
procedure ?
>-----Original Message-----
>CommandText = "SPfirst p1,p2,p3 EXEC SPNext p1, p2 EXEC

SPlast p1 "
>
>--
>____________________________________
>Bill Vaughn
>MVP, hRD
>www.betav.com
>Please reply only to the newsgroup so that others can

benefit.
>This posting is provided "AS IS" with no warranties, and

confers no rights.
>__________________________________
>
>"Venkatesh" <(E-Mail Removed)> wrote in message
>news:0dc601c36ca1$c946a310$(E-Mail Removed)...
>> I will need to execute several parametrized stored
>> procedures individually. What I am looking for is a

method
>> by which I can fill a collection of commandtext,command
>> type and parameter objects , construct a string and call
>> all the stored procedures at once without having to make
>> multiple round trips to the server.
>>
>>
>> >-----Original Message-----
>> >Stored procedures can call stored procedures.
>> >You can also submit a script that contains several SP

>> calls (or other TSQL
>> >code) and deal with the resultsets one-at-a-time.

Simply
>> construct a long
>> >string containing the TSQL and use ExecuteNonQuery or

>> Fill to execute it.
>> >
>> >--
>> >____________________________________
>> >Bill Vaughn
>> >MVP, hRD
>> >www.betav.com
>> >Please reply only to the newsgroup so that others can

>> benefit.
>> >This posting is provided "AS IS" with no warranties,

and
>> confers no rights.
>> >__________________________________
>> >
>> >"Venkatesh" <(E-Mail Removed)> wrote in message
>> >news:07b501c36be7$6a0b9ff0$(E-Mail Removed)...
>> >> Hi
>> >>
>> >> I want to execute multiple SQL Server stored

procedures
>> in
>> >> a single batch via ADO so that I can minimize network
>> >> trips. I need to pass in an array of caommandtype and
>> >> commandtext objects. What is the best way to do

this. Is
>> >> there an example anywhere on how to do this ?
>> >>
>> >> Thanks,
>> >>
>> >> Venkatesh
>> >
>> >
>> >.
>> >

>
>
>.
>

 
Reply With Quote
 
William \(Bill\) Vaughn
Guest
Posts: n/a
 
      27th Aug 2003
Nope, I was wrong. I thought this would work and it does not. ADO.NET won't
correctly parse more than one SP invocation in a single Command object.

However, you can call a single SP that calls several others on the server
end. In this case the Command object is setup normally.

--
____________________________________
Bill Vaughn
MVP, hRD
www.betav.com
Please reply only to the newsgroup so that others can benefit.
This posting is provided "AS IS" with no warranties, and confers no rights.
__________________________________

"Venkatesh" <(E-Mail Removed)> wrote in message
news:0f5401c36cb4$f262cc20$(E-Mail Removed)...
> Thanks Bill. How do I implement the commandtext and
> command parameters collections ? In other worrds, how do I
> associate the parameters with the relevant stored
> procedure ?
> >-----Original Message-----
> >CommandText = "SPfirst p1,p2,p3 EXEC SPNext p1, p2 EXEC

> SPlast p1 "
> >
> >--
> >____________________________________
> >Bill Vaughn
> >MVP, hRD
> >www.betav.com
> >Please reply only to the newsgroup so that others can

> benefit.
> >This posting is provided "AS IS" with no warranties, and

> confers no rights.
> >__________________________________
> >
> >"Venkatesh" <(E-Mail Removed)> wrote in message
> >news:0dc601c36ca1$c946a310$(E-Mail Removed)...
> >> I will need to execute several parametrized stored
> >> procedures individually. What I am looking for is a

> method
> >> by which I can fill a collection of commandtext,command
> >> type and parameter objects , construct a string and call
> >> all the stored procedures at once without having to make
> >> multiple round trips to the server.
> >>
> >>
> >> >-----Original Message-----
> >> >Stored procedures can call stored procedures.
> >> >You can also submit a script that contains several SP
> >> calls (or other TSQL
> >> >code) and deal with the resultsets one-at-a-time.

> Simply
> >> construct a long
> >> >string containing the TSQL and use ExecuteNonQuery or
> >> Fill to execute it.
> >> >
> >> >--
> >> >____________________________________
> >> >Bill Vaughn
> >> >MVP, hRD
> >> >www.betav.com
> >> >Please reply only to the newsgroup so that others can
> >> benefit.
> >> >This posting is provided "AS IS" with no warranties,

> and
> >> confers no rights.
> >> >__________________________________
> >> >
> >> >"Venkatesh" <(E-Mail Removed)> wrote in message
> >> >news:07b501c36be7$6a0b9ff0$(E-Mail Removed)...
> >> >> Hi
> >> >>
> >> >> I want to execute multiple SQL Server stored

> procedures
> >> in
> >> >> a single batch via ADO so that I can minimize network
> >> >> trips. I need to pass in an array of caommandtype and
> >> >> commandtext objects. What is the best way to do

> this. Is
> >> >> there an example anywhere on how to do this ?
> >> >>
> >> >> Thanks,
> >> >>
> >> >> Venkatesh
> >> >
> >> >
> >> >.
> >> >

> >
> >
> >.
> >



 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Common procedures for executing all stored procedure A1 Ronen Microsoft VB .NET 1 24th Dec 2005 12:28 PM
Executing Stored Procedures Nexus Microsoft Access ADP SQL Server 2 17th Sep 2004 11:22 PM
Error: Executing Stored Procedures-- Cannot Pass TimeStamp Values From sqlCommand Object Parameter to A SQL Stored Procedure =?Utf-8?B?VGVjaE1E?= Microsoft ADO .NET 3 17th Mar 2004 05:03 AM
Executing Master Stored Procedures Jim Heavey Microsoft ADO .NET 2 16th Dec 2003 08:58 PM
Executing stored procedures Andy Williams Microsoft Access ADP SQL Server 2 7th Nov 2003 03:44 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 11:22 PM.