T-SQL UPDATE with JOIN

I have two tables.  lets say a car table and a color table.   The color table has a single record per car and has a  FK to the car table.    I am moving the color directly into the car table.  I need to migrate existing data.  So, the new car table has a color column .

I'd like an UPDATE statement that does all records; that joins the two tables and updates the new color column in the car table based on the existing data in the color table.
LVL 1
HLRosenbergerAsked:
Who is Participating?

Improve company productivity with a Business Account.Sign Up

x
 
Éric MoreauConnect With a Mentor Senior .Net ConsultantCommented:
update c
set Color = col.Color
from car as C
inner join Color as col
on col.carid = c.id
0
 
HLRosenbergerAuthor Commented:
Thanks!
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.