Vote count:
0
I am attempting to update a table in one database with information from another table in a different database. On top of that I need a third table to establish the link between the two. Here's what I have:
Update
MT.dbo.[tblPatientEmployers]
Set
MT.dbo.[tblPatientEmployers].[PatientOccupation] = RTRIM(LTRIM(T.Field3)),
MT.dbo.[tblPatientEmployers].[PatientEmploymentStatusCode] = RTRIM(LTRIM(T.Field4)),
MT.dbo.[tblPatientEmployers].[PatientEmploymentFromDate] = RTRIM(LTRIM(T.Field5)),
MT.dbo.[tblPatientEmployers].[PatientEmploymentThruDate] = RTRIM(LTRIM(T.Field6)),
MT.dbo.[tblPatientEmployers].[PatientEmployerPhoneNumber] = RTRIM(LTRIM(T.Field7)),
MT.dbo.[tblPatientEmployers].[PatientNationalEmployerID] = RTRIM(LTRIM(T.Field8)),
MT.dbo.[tblPatientEmployers].[PatientEmployerName] = RTRIM(LTRIM(T.Field9)),
MT.dbo.[tblPatientEmployers].[PatientEmployerAddress1] = RTRIM(LTRIM(T.Field11)),
MT.dbo.[tblPatientEmployers].[PatientEmployerAddress2] = RTRIM(LTRIM(T.Field12)),
MT.dbo.[tblPatientEmployers].[PatientEmployerCity] = RTRIM(LTRIM(T.Field13)),
MT.dbo.[tblPatientEmployers].[PatientEmployerStateCode] = RTRIM(LTRIM(T.Field15)),
MT.dbo.[tblPatientEmployers].[PatientEmployerZipCode] = RTRIM(LTRIM(T.Field16))
from [MT_Work].[dbo].[impHL7Xref] as T
inner join [MT_Work].[dbo].[impHL7Xref] ON MT.dbo.tblPatients.[MedicalRecordNumber] = [MT_Work].[dbo].[impHL7Xref].MRN
WHERE
T.RecordType = 'PATEMP'
Which results in the error message: Msg 4104, Level 16, State 1, Line 20 The multi-part identifier "MT.dbo.tblPatients.MedicalRecordNumber" could not be bound.
asked 1 min ago
SQL Update Table Based On Data From Another Database
Aucun commentaire:
Enregistrer un commentaire