iasher (8/4/2014)
The table referenced in the FROM clause ("attorney") is actually the source table, but it's the target table (@IA_CourtCostReport) that's causing the problem, so I'm not sure how to reference that with an alias when it shouldn't be in the FROM clause. I'm not getting any data FROM the table variable.
Yes, it should be in the FROM clause. It has to be in this case because you cannot refer to it in your join condition otherwise.
If you look in Books Online, the full form of the update.. from is
UPDATE <target>
FROM <target> <join> <source> ON ...
Which means you can (and need to) define a table alias for the table variable.
The SELECT is fine because you never try to do @TableVar.ColumnName, which is what is not allowed.
Gail Shaw
Microsoft Certified Master: SQL Server, MVP, M.Sc (Comp Sci)
SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability