I've found a very common belief among users of T-SQL (both DBAs and Developers) is that you can't use an alias with the UPDATE statement. As best I can tell the reason for this is because of a simple misunderstanding of the UPDATE command syntax.
The basic syntax of a table alias is as follows. SELECT column1, column2.... FROM table_name AS alias_name WHERE [condition];
The alias doesn't affect performance in any practical or measurable way at all (italics added on edit). That is, it would add a barely (if it all) measurable delay to query compilation. Once compiled (and re-used), it has no effect.
SQL aliases are used to give a table, or a column in a table, a temporary name. Aliases are often used to make column names more readable. An alias only exists for the duration of that query. An alias is created with the AS keyword.
UPDATE ra
SET ra.ItemValue = rb.ItemValue
FROM dbo.Rates ra
INNER JOIN dbo.Rates rb
ON ra.ResourceID = rb.ResourceID
WHERE ra.PriceSched = 't8'
AND rb.PriceSched = 't9';
This might help in improving performance.
Table alias in Update Query in T-SQL( Microsoft SQL) . for MS SQL Server 2008 R2 it's work just fine
UPDATE A_GeneralLedger set ScheduleId=g.ScheduleId
from A_GeneralLedger l inner join A_AcGroup g on g.ACGroupID=l.AccountGroupID
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With