Tuesday, March 27, 2012

Exec SP with @Param in external file

Hi I have googled but could not find the answer how can I do the
following.
exec my_sp < foo.csv
I.e feed my_sp with the contents of a external file?
my_sp expects one parameter @.param1
the csv file or tsv or whatever looks like this:
1
2
3
4
5
6
7
8
9
10
.....
is this poss?
thanksYou could easily use VB or VBScript to open the file using
Scripting.FileSystemObject, read through line by line, and EXEC the SP using
the value found on each line.
This will be much more difficult (though not impossible) to construct in
T-SQL, and I recommend you do this kind of processing outside of the
database and use T-SQL as a last resort.
"red" <cap_sch@.yahoo.co.uk> wrote in message
news:1124113881.153729.316840@.g14g2000cwa.googlegroups.com...
> Hi I have googled but could not find the answer how can I do the
> following.
> exec my_sp < foo.csv
> I.e feed my_sp with the contents of a external file?
> my_sp expects one parameter @.param1
> the csv file or tsv or whatever looks like this:
> 1
> 2
> 3
> 4
> 5
> 6
> 7
> 8
> 9
> 10
> .....
> is this poss?
>
> thanks
>|||sp must first establist an openrowset, openquery
or a linkedserver to the csv parameter
sp must then throw the query
to the establish connection
"red" wrote:

> Hi I have googled but could not find the answer how can I do the
> following.
> exec my_sp < foo.csv
> I.e feed my_sp with the contents of a external file?
> my_sp expects one parameter @.param1
> the csv file or tsv or whatever looks like this:
> 1
> 2
> 3
> 4
> 5
> 6
> 7
> 8
> 9
> 10
> ......
> is this poss?
>
> thanks
>|||If we can have a look at your procedure, maybe we can suggest a set-based
solution. After all - T-SQL is set-oriented.
ML

No comments:

Post a Comment