Showing posts with label Queries. Show all posts
Showing posts with label Queries. Show all posts

Tuesday, July 8, 2008

Update a table with data from a view

Well this was my first (that I can remember) update query using data from an outside source - in this case, a view. It was actually documented quite clearly in Books Online. Nevertheless, code example, in case it is of use:


UPDATE table SET table.apple = v.apple
FROM table as t
INNER JOIN view as v
ON t.id = v.id


Why I had to use aliases for this to work is more than I understand. Explanations? Comments?