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 gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

New to SQL need help with cursor

Status
Not open for further replies.

smithsf22

Programmer
Mar 13, 2006
5
CA
Hello, I get the error :

"Cursorfetch: The number of variables declared in the INTO list must match that of selected columns."

when I run the below cursor:

DECLARE TempCountCursor Cursor FOR
SELECT COUNT(*) as TotalCount
FROM v_job_costing_report
WHERE invoice_no = @invoice_no
OPEN TempCountCursor
BEGIN
FETCH NEXT FROM JobCostingCursor
INTO @temp_count
CLOSE TempCountCursor
DEALLOCATE TempCountCursor

It should return only one integer number so I do not understad why I get the above error. This cursor is run within a cursor, I did not know if I can do that and I wonder if that is the problem. I am new at SQL

Thanks for the help.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top