Re: Cursor for loops
From: David Portas (REMOVE_BEFORE_REPLYING_dportas_at_acm.org)
Date: 10/12/04
- Next message: jez123456: "Splitting Records 2"
- Previous message: David Portas: "Re: Cursor for loops"
- In reply to: Arun: "Re: Cursor for loops"
- Next in thread: Arun: "Re: Cursor for loops"
- Reply: Arun: "Re: Cursor for loops"
- Reply: Arun: "Re: Cursor for loops"
- Messages sorted by: [ date ] [ thread ]
Date: Tue, 12 Oct 2004 04:05:04 -0700
> Normally I use the cursor to go through a set of rows and do some actions
> with the values from each row (like calling another procedure, passing a
> column value from that row). How can I achieve the same with the 'set based
> code'?
See the reply I posted in response to Ian. If you *must* invoke a stored
procedure for each row then yes, you have to use a cursor or equivalent
procedural loop. But if that SP just performs straight data manipulation then
you're probably better off rewriting it so that you can perform the operation
once for a whole data set rather than individually for each row. There isn't
a generic answer to your question because it depends on what the SP does.
-- David Portas SQL Server MVP -- "Arun" wrote: > Hi David, > > Can you please let me know how to use the 'set based code' for substituting > the cursor usage? > Normally I use the cursor to go through a set of rows and do some actions > with the values from each row (like calling another procedure, passing a > column value from that row). How can I achieve the same with the 'set based > code'? > > Arun > > > > "David Portas" <REMOVE_BEFORE_REPLYING_dportas@acm.org> wrote in message > news:E20E1465-2111-491E-856A-ACD237144E94@microsoft.com... > > SQL Server has a WHILE loop... but cursors, loops and procedural > processing > > are best avoided. Try to write set-based code for all your data > manipulation. > > Post here if you need help. > > > > -- > > David Portas > > SQL Server MVP > > -- > > > > >
- Next message: jez123456: "Splitting Records 2"
- Previous message: David Portas: "Re: Cursor for loops"
- In reply to: Arun: "Re: Cursor for loops"
- Next in thread: Arun: "Re: Cursor for loops"
- Reply: Arun: "Re: Cursor for loops"
- Reply: Arun: "Re: Cursor for loops"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|