mcnewsxp
unread,Apr 11, 2013, 6:31:02 PM4/11/13You do not have permission to delete messages in this group
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to
i have an AccountEntry table that contains OwnerID, AccountID, AccountPeriodID.
i need to get the distinct OwnerID, distinct AccountID and distinct AccountPeriodID and then execute 3 while loops to call a stored proc with the values ala
while ownerid loop has values
while accountid loop has values
while ownerid loop has values
exec storedproc ownerid, accountid, accountperiodid
read new accountperiodid value
end loop
read new accountid
end loop
read ownerid
end loop
i know how to use
BEGIN
EXEC myproc
FETCH NEXT FROM OwnerCursor INTO @OwnerID
ENDWHILE @@FETCH_STATUS = 0
but not how to do nested loops.
thanks in advance.
CREATE TABLE [dbo].[AccountEntry](
[AccountingEntryID] [int] IDENTITY(1,1) NOT NULL,
[AccountingPeriodID] [int] NULL,
[AccountID] [int] NOT NULL,
[OwnerID] [int] NULL,
CONSTRAINT [PK_AccountingEntry] PRIMARY KEY CLUSTERED
1, 1, 1
1, 2, 1
2, 23, 3
3, 4, 5