Alex Watts
Alex Watts

Reputation: 567

The Multi-part identifier could not bound

I've read the other posts on this issue and I haven't really found one that receives this error from the situation I have.

For the following query:

INSERT INTO dbo.EightIDs (Email)
    SELECT Email
    FROM dbo.TempTransferTable
    WHERE dbo.TempTransferTable.EightID = dbo.EightIDs.EID

I receive an error

Multi-part identifier could not be bound

on the dbo.EightIDs.EID part of the query. I'm not sure why it's giving me a problem when I'm basically just trying to match the IDs in one table with the IDs in a second table, then bring over the Emails accordingly.

EDIT:

Based on the comments about using UPDATE with a JOIN, here's what I came up with. Does this seem more appropriate?

UPDATE tbl1
SET tbl1.Email = tbl2.Email
FROM dbo.EightIDs tbl1
JOIN dbo.TempTransferTable tbl2 ON tbl2.EightID = tbl1.EID

Upvotes: 1

Views: 3018

Answers (1)

Arulkumar
Arulkumar

Reputation: 13237

You need to mentioned the table name or alias name in front of the column name. Hope the Email column is exists in the both tables:

INSERT INTO dbo.EightIDs (Email)
SELECT TT.Email
FROM dbo.TempTransferTable TT
JOIN dbo.EightIDs EI ON EI.EID = TT.EightID 

Or if you want to UPDATE the column to EightIDs based on TempTransferTable, you can use the below query:

UPDATE EI
SET EI.Email = TT.Email
FROM dbo.EightIDs EI
JOIN dbo.TempTransferTable TT ON TT.EightID = EI.EID

Upvotes: 1

Related Questions