Re: Looping over a query
From: Chris (christopher_at_reardenweb.com)
Date: 09/07/04
- Next message: Roji. P. Thomas: "Re: using case statements within a where clause"
- Previous message: Tim Cowan: "Can I pass an array to an SP?"
- Maybe in reply to: Chris: "Looping over a query"
- Next in thread: Roji. P. Thomas: "Re: Looping over a query"
- Messages sorted by: [ date ] [ thread ]
Date: Tue, 7 Sep 2004 10:42:52 -0500
I need to loop over the results because they are being inserted into another
table as:
@Group1
@Group2
@Group3
@Group4
@Group5
In the past these were hard coded to the stored proc that is using them. Now
we are databasing them because the end user has the choice to rename them.
Below is a portion of the stored proc that uses these values:
Insert Into @UniqueGroupNames Values (@Group1)
If ( @@ERROR <> 0 ) Begin
Select @ErrValue = @@ERROR
Return
End
Insert Into @UniqueGroupNames Values (@Group2)
If ( @@ERROR <> 0 ) Begin
Select @ErrValue = @@ERROR
Return
End
@UniqueGroupNames is a temp table.
"Adam Machanic" <amachanic@hotmail._removetoemail_.com> wrote in message
news:O9l899OlEHA.2892@tk2msftngp13.phx.gbl...
> Chris,
>
> Could you go into some more detail on what exactly you're trying to
> accomplish? I'm confused as to why you feel you might need to loop over
> anything if your query will always return exactly 5 rows. Are you looking
> for a row numbering scheme? If so, please read:
>
> http://www.aspfaq.com/show.asp?id=2427
>
>
> "Chris" <christopher@reardenweb.com> wrote in message
> news:%23I7VU5OlEHA.644@tk2msftngp13.phx.gbl...
> > Hi all,
> >
> > I have a question on looping over results. I have the following select
> > statement:
> >
> > SELECT FactorLabel
> > FROM RFMFactorLabels
> > WHERE ClientKey = @ClientKey
> >
> > The results would be something like:
> > Frequency Group 1
> > Frequency Group 2
> > Frequency Group 3
> > Frequency Group 4
> > Frequency Group 5
> >
> > There will always be 5 results and only 5. I need to loop over the
results
> > and set them as:
> > @Group 1 = "the first result"
> > @Group2 = "the second result" and so on and so on.
> >
> >
> > Can someone point me in the right direction?
> >
> > Thanks.
> >
> >
>
>
- Next message: Roji. P. Thomas: "Re: using case statements within a where clause"
- Previous message: Tim Cowan: "Can I pass an array to an SP?"
- Maybe in reply to: Chris: "Looping over a query"
- Next in thread: Roji. P. Thomas: "Re: Looping over a query"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|