[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

microsoft.public.sqlserver.programming

Run a Stored Procedure for every row in a select?

jobs

3/21/2007 4:14:00 PM

Do I need a cursor to do this?

6 Answers

Aaron [SQL Server MVP]

3/21/2007 4:22:00 PM

0

Yes, that is one solution. A much better solution is to re-work the stored
procedure logic (or create a separate procedure) so that it can deal with a
set instead of dealing with each row individually. Dealing with each row
individually (using a cursor, or while loop) can be very taxing on the
server.

--
Aaron Bertrand
SQL Server MVP
http://www.sq...
http://www.aspfa...



"jobs" <jobs@webdos.com> wrote in message
news:1174493626.187728.72470@b75g2000hsg.googlegroups.com...
> Do I need a cursor to do this?
>


bob

3/22/2007 12:18:00 PM

0

I have grown fond of using sqlcmd mode:

Put Management Studio into sqlcmd mode first ( from main menu: Query,
SQLCMDMode ) - you'll know if it's worked as the :out lines will go grey.

SET NOCOUNT ON

:out c:\temp\temp.sql

SELECT 'SELECT TOP 10 * FROM ' + name AS GO FROM sys.tables
GO

-- You could always put:
-- SELECT 'DROP TABLE ' + name AS GO FROM sys.tables

:out STDOUT

-- Read the file you've created dynamically
:r c:\temp\temp.sql

SET NOCOUNT OFF

Obviously you can't do this easily in a stored proc.

wBob
"jobs" wrote:

> Do I need a cursor to do this?
>
>

smith.jeff28

4/4/2008 1:23:00 AM

0


BarbaraSchwarz: If you want to convince anyone, stop your nattering
and produce evidence.

This is the true subject line, but BarbaraSchwarz is ashamed an afraid
of this subject, so she must change it.
She can't bear for anyone to find out this simple truth.

smith.jeff28

4/4/2008 1:32:00 AM

0

The great part is BarbaraSchwarz: thinks she is helping her cause,
when anyone can see that her repeatative nattering is what it's all
about.

I'm just helping her show everyone the true nature of her Scamolgy.

haxor99

4/4/2008 1:42:00 AM

0



She will never have anything to say other than "lies all lies"

That has bee the party line since Hubbie boy came up with it.
Now that we are wining big, it does not fly.
Even the LA org finally admits that Hubbie was not ever a Nuclear
Physicist and that he flunked out of school, had no formal training
in anything.
So if he lied and they lied about that, what else did they lie about?

barb

4/4/2008 5:17:00 PM

0

haxor99@gmail.com wrote:
>
> She will never have anything to say other than "lies all lies"
>
> That has bee the party line since Hubbie boy came up with it.
> Now that we are wining big, it does not fly.
> Even the LA org finally admits that Hubbie was not ever a Nuclear
> Physicist and that he flunked out of school, had no formal training
> in anything.
> So if he lied and they lied about that, what else did they lie about?

"That's NUKulear!" </homersimpson>

--
Barb
Chaplain, ARSCC (wdne)
It's Poodlin' Time!

?I think that the protections that we enjoy for freedom of worship exist
so long as we don?t step over the line. When religious worship and
belief cross over into things like fraud, victimization of others and
the disruption of the political arena, that protection is no longer
appropriate.?

--Robert Goff
Professor Emeritus, UCSC