Today I have learnt that we can use the alias name in the Update statement in SQL Server. I thought it would be helpful if I post this. Below is the explanation for this
We have taken a table that need to be updated by joining multiple tables. Here, we can see that in the “Update table” statement we have used an alias name “emp”:
UPDATE emp SET ename = temp.ename FROM #WTemp_Emp temp INNER JOIN dbo.TBL_Employee emp ON emp.EmpID=temp.EmpID
The above statement updates the ename in EMP table in the database by joining the two table emp and temp table (which contains the eid, ename information).