I’m getting an error message when running the follwoing SQL statement. It’s a pretty basic statement and I’ve got to be overlooking something REALLY simple.
If I remove the alias, the statement executes just fine. Add the alias back in and I get the error.
The message in SSMS:
Msg 4104, Level 16, State 1, Line 2
The multi-part identifier "T1.titleId" could not be bound.
The SQL statement:
UPDATE People
SET T1.titleId = T2.ID
FROM people as T1
INNER JOIN titles as T2
ON T1.title = T2.Title
Update 1 – The comma is not part of the statement and I’m still getting the error.
Try this:
It can not find T1.titleId because you are updating “Person” and sql can only see the Person tables that you aliased as T1 and T2. So you would want to update T1 in your case. Also you had an extra comma in your inner join.