Error with Cursor and Into list must match.

I'm trying to build a cursor out and I'm getting an error on my into statement. I don't get why because I'm calling 4 columns and trying to place 4 columns? What am I missing?

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

 Begin
	   Declare c Cursor For Select equModelNum equipTypeId, manfId, equLink From tblEquipment
       Open c
       Declare @equModelNum nvarchar(100)
	   Declare @equipTypeId int
	   Declare @manfId int
	   Declare @equLink nvarchar(150)
	   Fetch next From c into @equModelNum, @equipTypeId, @manfId, @equLink
	   While @@Fetch_Status=0 Begin
          
          if @equModelNum <> '0'
                 Declare @equipTypeIdName nvarchar(50)
                 Declare @manfIdName nvarchar(50)
				 Declare @NewequipTypeId int
                 Declare @NewmanfId int
                 Set @equipTypeIdName = (Select Equipment_Type from tblEquipmentType where equipTypeID = @equipTypeId)
                 Set @manfIdName = (Select Manufacture_Name from tblManufacturer where manfId=@manfId)
				 print @equModelNum
				 print @equipTypeId
				 print @manfId
				 print @equLink
				 Print @equipTypeIdName
				 print @manfIdName
               
          Fetch next From c into @equModelNum, @equipTypeId, @manfId, @equLink
       End
 
       Close c
       Deallocate c
	   End

Open in new window

NickMalloySystems LeadAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Aneesh RetnakaranDatabase AdministratorCommented:
you missed a  comma here
Declare c Cursor For Select equModelNum , equipTypeId, manfId, equLink From tblEquipment
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Jim HornMicrosoft SQL Server Developer, Architect, and AuthorCommented:
In the below line there is a comma missing between equModelNum and equipTypeId.
 Declare c Cursor For Select equModelNum equipTypeId, manfId, equLink From tblEquipment

Open in new window

0
Aneesh RetnakaranDatabase AdministratorCommented:
Did you miss the first post  ?
0
Jim HornMicrosoft SQL Server Developer, Architect, and AuthorCommented:
Nick

Normal EE protocol is that if two answers are very identical, either the first one gets all the points, or points are split between them.

I'll take the liberty of re-opening this question so you can re-award points.

Thanks in advance.
Jim
0
NickMalloySystems LeadAuthor Commented:
When I was awarding points I accidentally selected Jimhorn when I thought I was selecting yours. When I said accept answer, yours was the only response to the question. I don't see a way to correct this? Is there a way? I'd like to award you points????
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft SQL Server

From novice to tech pro — start learning today.