469,929 Members | 1,770 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,929 developers. It's quick & easy.

Results of SQL SELECT statement into Stored Procedure

I need to run a stored procedure on all the results of a select query.

For a simplified example, I'd like to be able to do something like
this:

SELECT JobID, QtyToAdd
FROM Jobs
WHERE QtyToAdd > 0

Then for the results of the above:

EXEC sp_stockadd @JobID, @QtyToAdd

Where the above line ran for every result from the above select query.

Anyone able to shed some light on how to do this?

Many thanks,
James

Jul 23 '05 #1
2 2155

<ja*****@gmail.com> wrote in message
news:11*********************@g14g2000cwa.googlegro ups.com...
I need to run a stored procedure on all the results of a select query.

For a simplified example, I'd like to be able to do something like
this:

SELECT JobID, QtyToAdd
FROM Jobs
WHERE QtyToAdd > 0

Then for the results of the above:

EXEC sp_stockadd @JobID, @QtyToAdd

Where the above line ran for every result from the above select query.

Anyone able to shed some light on how to do this?

Many thanks,
James


Rewriting your proc to work on a set of data, not on a single JobID would
probably be the best option, otherwise see this thread:

http://groups-beta.google.com/group/...fc0760e026886e

By the way, don't use the sp_ prefix for stored procs - it's reserved for
system procs, and MSSQL will try to find it in the master database before
looking in a user one.

Simon
Jul 23 '05 #2
I searched for hours yesterday, and for some reason never came across
that other post of yours - Thanks!

James

Jul 23 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

reply views Thread by Jason MacKenzie | last post: by
2 posts views Thread by Sandy | last post: by
2 posts views Thread by =?Utf-8?B?VGVycnk=?= | last post: by
10 posts views Thread by Steve | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.