Re: Looping over a query

From: Chris (christopher_at_reardenweb.com)
Date: 09/07/04


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.
> >
> >
>
>



Relevant Pages

  • Re: Nested Security Groups in Mail enabled security groups
    ... > to group1 all users get the message. ... I create another group called group2 ... > Every position is a security group, every sub departement is a security ... > group and every department is a security group and all of the groups are ...
    (microsoft.public.exchange.admin)
  • Nested Security Groups in Mail enabled security groups
    ... Windows 2003 native domain with Windows 2003 native forest, ... to group1 all users get the message. ... I create another group called group2 ... Every position is a security group, every sub departement is a security ...
    (microsoft.public.exchange.admin)
  • range referencing

    (microsoft.public.excel.programming)
  • Re: Problems with GPO
    ... I see that you applied that to Group1 and Group2 and thatz fine. ... The policy you applied should not affect other users even if thatz ...
    (microsoft.public.windows.server.active_directory)