Mitchel Stuart Fountaine Mitchel Stuart Fountaine - 2 months ago 7
SQL Question

Multi-Part Identifier could not be bound - Moving column and data to different table

SELECT Contract as CaseRef, DateTime, Username
INTO #tempDB
FROM callhandlinginfo

INSERT INTO CallHandlingInfo(Event)
FROM tblComplianceData
WHERE tblComplianceData.CaseRef = #tempdb.CaseRef

SELECT * FROM CallHandlingInfo

I get error

Multi-Part Identifier could not be bound.

Thanks all for the response, I see my mistake! What would it look like if it were an
statement instead?


My best guess on what you want to accomplish is:

INSERT INTO CallHandlingInfo(Event)
    SELECT Event
    FROM tblComplianceData cd
    WHERE cd.CaseRef IN (SELECT cr.CaseRef FROM #tempdb.CaseRef cr);

You might want an update. Assuming SQL Server, it might look like this:

update chi
    set event = cd.event
    from callhandlinginfo chi join
         tblComplianceData cd
         on cd.CaseRef = chi.CaseRef;