Re: Passing Table to SP More Info by Andrew
Andrew
Fri Feb 18 11:52:46 CST 2005
To answer my own question, I did a bit of instrumentation on this.
1. SELECT NewID(); SELECT NewID(); SELECT NewID(); ..... 1000 times and fill
it into a single DataSet using a DataAdaptor.
or
2. SELECT NewID(); and loop through 1000 times with a
Command.ExecuteScalar() and leaving the connection open.
the latter was about 3 to 4 times faster.
-Andrew
"Andrew" <nemoby@nospam.nospam> wrote in message
news:u6IRoeWFFHA.3908@TK2MSFTNGP12.phx.gbl...
> Kevin,
>
> Yes, I think you have a good handle on what I want to do. Didn't think
> there was any way to pass a table. I guess I could pass XML with Yukon,
> but that will have to wait. So, yes, I can make multiple calls to the same
> sproc and even do that as a single round trip to SQL by using a single
> call.
>
> 1. Is there a way that I can use Parameter.Add to build each 'sub-call'
> and then concatenate the resulting string before passing the whole thing
> off to SqlCommand? Mainly interested in avoiding sql injection type
> issues. I have always coded with parameters and would like to continue
> using them.
>
> 2. If each of the sprocs returns a single scalar value, (in this case a
> guid), is it reasonable to use my concatenated sql query with a
> DataSet.Fill method and in effect return 'n' number of tables. Then
> iterate through the table collection on the dataset, each table having a
> single row and column. If I passed 200-300 subqueries to sql and wound up
> with 200-300 tables in the DataSet, am I pushing the limits? Is there an
> upper limit? Is this a reasonable approach?
>
>
> thanks,
>
> "Kevin Yu [MSFT]" <v-kevy@online.microsoft.com> wrote in message
> news:ZCdoL7VFFHA.3612@TK2MSFTNGXA01.phx.gbl...
>> Hi Andrew,
>>
>> First of all, I would like to confirm my understanding of your issue.
>> From
>> your description, I understand that you need pass a whole DataTable to
>> the
>> stored procedure as parameter. If there is any misunderstanding, please
>> feel free to let me know.
>>
>> As far as I know, we cannot pass a whole table to the stored procedure,
>> as
>> SQL doesn't accept such type. So what I suppose, is to call the same
>> sproc
>> n number of times as you mentioned. This is the workaround for the
>> limitation.
>>
>> HTH.
>>
>> Kevin Yu
>> =======
>> "This posting is provided "AS IS" with no warranties, and confers no
>> rights."
>>
>
>