Cursor help

  • HI

    after definnig a cursor whice have more then one field how do i access aspecific field on the cursor?

    for example:

    DECLARE Employee_Cursor CURSOR FOR

    SELECT LastName, FirstName

    FROM Northwind.dbo.Employees

    OPEN Employee_Cursor

    FETCH NEXT FROM Employee_Cursor

    HOW DO I ACCES THE FIELD FirstName ?

    Employee_Cursor.FirstName  ??? (DOSENT WORK)

    I seen example with the fetch into but it was for a single field cursor.

    thanks

  • declare @FirstName varchar(100)

    declare @LastName varchar(100)

    FETCH NEXT FROM Employee_Cursor INTO @LastName, @FirstName

     

  • Is there no other way, what if i have a cursor with 20 fields ?

    thanks

  • 20 fields = 20 variables I am afraid!!!

    Have you tried avoiding the use of a cursor by using temp tables instead?

Viewing 4 posts - 1 through 3 (of 3 total)

You must be logged in to reply to this topic. Login to reply