Avatar of NickMalloy
NickMalloyFlag for United States of America

asked on 

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

Microsoft SQL Server

Avatar of undefined
Last Comment
NickMalloy
ASKER CERTIFIED SOLUTION
Avatar of Aneesh
Aneesh
Flag of Canada image

Blurred text
THIS SOLUTION IS ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
Avatar of Jim Horn
Jim Horn
Flag of United States of America image

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

Avatar of Aneesh
Aneesh
Flag of Canada image

Did you miss the first post  ?
Avatar of Jim Horn
Jim Horn
Flag of United States of America image

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
Avatar of NickMalloy
NickMalloy
Flag of United States of America image

ASKER

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????
Microsoft SQL Server
Microsoft SQL Server

Microsoft SQL Server is a suite of relational database management system (RDBMS) products providing multi-user database access functionality.SQL Server is available in multiple versions, typically identified by release year, and versions are subdivided into editions to distinguish between product functionality. Component services include integration (SSIS), reporting (SSRS), analysis (SSAS), data quality, master data, T-SQL and performance tuning.

171K
Questions
--
Followers
--
Top Experts
Get a personalized solution from industry experts
Ask the experts
Read over 600 more reviews

TRUSTED BY

IBM logoIntel logoMicrosoft logoUbisoft logoSAP logo
Qualcomm logoCitrix Systems logoWorkday logoErnst & Young logo
High performer badgeUsers love us badge
LinkedIn logoFacebook logoX logoInstagram logoTikTok logoYouTube logo