Solved

T-SQL UPDATE with JOIN

Posted on 2015-01-21
3
100 Views
Last Modified: 2015-01-21
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.
0
Comment
Question by:HLRosenberger
3 Comments
 
LVL 69

Accepted Solution

by:
Éric Moreau earned 500 total points
ID: 40562847
update c
set Color = col.Color
from car as C
inner join Color as col
on col.carid = c.id
0
 
LVL 1

Author Closing Comment

by:HLRosenberger
ID: 40562884
Thanks!
0

Featured Post

Complete VMware vSphere® ESX(i) & Hyper-V Backup

Capture your entire system, including the host, with patented disk imaging integrated with VMware VADP / Microsoft VSS and RCT. RTOs is as low as 15 seconds with Acronis Active Restore™. You can enjoy unlimited P2V/V2V migrations from any source (even from a different hypervisor)

Join & Write a Comment

Long way back, we had to take help from third party tools in order to encrypt and decrypt data.  Gradually Microsoft understood the need for this feature and started to implement it by building functionality into SQL Server. Finally, with SQL 2008, …
In this article we will get to know that how can we recover deleted data if it happens accidently. We really can recover deleted rows if we know the time when data is deleted by using the transaction log.
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, Just open a new email message.  In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…

760 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now