TSQL - Update using an inner join

Sometimes you want to update a table and require a join with another table. The achieve this use the following construction.

UPDATE t1
SET t1.CalculatedColumn = t2.[Calculated Column]
FROM dbo.Table1 AS t1
INNER JOIN dbo.Table2 AS t2 ON t1.CommonField = t2.[Common Field]
WHERE t1.BatchNo = '110';

Add comment

biuquote
  • Comment
  • Preview
Loading

Sponsored by

Calendar

<<  November 2018  >>
MoTuWeThFrSaSu
2930311234
567891011
12131415161718
19202122232425
262728293012
3456789

View posts in large calendar

RecentComments

TextBox