Mitchel Stuart Fountaine Mitchel Stuart Fountaine - 1 year ago 74
SQL Question

Multi-Part Identifier could not be bound - Moving colum 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 UPDATE Statement instead?

Answer Source

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;
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download