Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Rhinorhino on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Cursor with stored procedure as source 1

Status
Not open for further replies.

grnzbra

Programmer
Joined
Mar 12, 2002
Messages
1,273
Location
US
I have a stored procedure which, when called from the query analyzer, gives a set of records.

My understanding of a cursor is that it is declared sort of as follows:

DECLARE csrDesk CURSOR
LOCAL
FORWARD_ONLY
STATIC
READ_ONLY
FOR
SELECT d.Desks, d.Average_Desk_Cost
FROM Desk_Costs d
WHERE d.Office_No = @OffNo AND MONTH(d.Desk_Date) = MONTH(@EnDt) AND YEAR(d.Desk_Date) = YEAR(@EnDt)
 
After some reflection I don't think what you want done can be done with set-based processing.

Good luck!
 
It does work. I put a "Print" statement at various points in the loop and could see each record being processed.
 
You are using a loop... not set operations.
 
Set-based operations:

[tt]UPDATE Table SET Field = Expression WHERE Condition[/tt]

Loop-based operations:

[tt]For i = 1 to 100
Update Record #i With Expression
Next[/tt]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top