Link to home
Start Free TrialLog in
Avatar of team2005
team2005

asked on

How to make For loop stored procedure

Hi!

Have a table that contains of 2 fields...
And have another table, that links to this table

TABLEA
OrderID (Key)
Dato

TABLEB
OrderID (key)
Felt1
Felt2
Felt3
Felt4


How do i make this, when i want to get OrderID from TableA ->@OrderID
and use this in this query for TABLEB
Select (*) from TABLEB where TABLEB.OrderID = @OrderID
..
..
ASKER CERTIFIED SOLUTION
Avatar of Wim_Bl
Wim_Bl
Flag of Belgium image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of team2005
team2005

ASKER

Hi!

Must loop TABLEA and get @ORDERID like

For i=1 to (select count(*) from TableA
     @ORDERID = TABLEA.Orderid
     NEXT RECORD...
     IF (select count(*) from TABLEB Where TABLEB.Orderid = @ORDERID
     BEGIN
           ....
      ELSE
          .....
     END IF
next i

Hope you anderstand
Thanks