How to write UPDATE SQL with Table alias in SQL Server 2008? How to write UPDATE SQL with Table alias in SQL Server 2008? sql sql

How to write UPDATE SQL with Table alias in SQL Server 2008?


The syntax for using an alias in an update statement on SQL Server is as follows:

UPDATE QSET Q.TITLE = 'TEST'FROM HOLD_TABLE QWHERE Q.ID = 101;

The alias should not be necessary here though.


You can always take the CTE, (Common Tabular Expression), approach.

;WITH updateCTE AS(    SELECT ID, TITLE     FROM HOLD_TABLE    WHERE ID = 101)UPDATE updateCTESET TITLE = 'TEST';