troubleshooting Question

Error with Cursor and Into list must match.

Avatar of NickMalloy
NickMalloyFlag for United States of America asked on
Microsoft SQL Server
5 Comments1 Solution336 ViewsLast Modified:
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
Join the community to see this answer!
Join our exclusive community to see this answer & millions of others.
Unlock 1 Answer and 5 Comments.
Join the Community
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 5 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros