Update table.column with another table.column with common joined column
- by Matt
Hit a speed bump, trying to update some column values in my table from another table.
This is what is supposed to happen when everything works
Correct all the city, state entries in tblWADonations by creating an update statement that moves the zip city from the joined city/state zip field to the tblWADonations city state
TBL NAME | COLUMN NAMES
tblZipcodes with zip,city,State
tblWADonations with zip,oldcity,oldstate
This is what I have so far:
UPDATE tblWADonations
SET oldCity = tblZipCodes.city, oldState = tblZipCodes.state
FROM tblWADonations INNER JOIN
tblZipCodes ON tblWADonations.zip = tblZipCodes.zip
Where oldCity <> tblZipcodes.city;
There seems to be easy ways to do this online but I am overlooking something. Tried this by hand and in editor this is what it kicks back.
Msg 8152, Level 16, State 2, Line 1
String or binary data would be truncated.
The statement has been terminated.
Please include a sql statement or where I need to make the edit so I can mark this post as a reference in my favorites. Thanks!