Link to home
Start Free TrialLog in
Avatar of CipherIS
CipherISFlag for United States of America

asked on

SQL - Error "The Multi-Part Identifier could not be found"

I have the below code.  I am testing a script before I run it in production.  The Table variable @PART is populated with data.  I'm using a loop to populate @PART2.

I'm receiving an error here -> (#Temp.scheme, #temp.value, #temp.label, #temp.description, #temp.label, #temp.description)
DECLARE @PART AS Table (
	ID			INT IDENTITY PRIMARY KEY NOT NULL,
	scheme		INT, 
	value		VARCHAR(16), 
	label		text, 
	description	text
)

DECLARE @PART2 AS Table (
	scheme				INT, 
	value				VARCHAR(16), 
	label				text, 
	description			text,
	html_label			text, 
	html_description	text
)

--Populate data in @Part2 .....

DECLARE @Records INT = (SELECT Count(*) FROM @PART)

DECLARE @count INT = 1

WHILE @count < @Records
	BEGIN
		SELECT * INTO #Temp FROM @PART WHERE ID = @count

		INSERT INTO @PART2
		(scheme, value, label, description, html_label, html_description)
		VALUES
		(#Temp.scheme, #temp.value, #temp.label, #temp.description, #temp.label, #temp.description)
		
		DROP TABLE #Temp
		
		SET @count = @count + 1
	END
--WEND

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of Shaun Kline
Shaun Kline
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of CipherIS

ASKER

Thanks