Solved

Update based on Select

Posted on 2006-07-11
2
228 Views
Last Modified: 2012-05-05
I think that this is really easy, I just have never done it before.

Basically I have a two columned table: table1

It has the columns id, and name

talble1: (all have names)
-id
-name

Then I have

table2: (Some names are null)
-id
-name

I basically want to go through table2 and for any null names use the id to look up the name in table1 and then update table2 with this name.

Thanks

~Matthew
0
Comment
Question by:Zeman4323
2 Comments
 
LVL 25

Accepted Solution

by:
Mr_Peerapol earned 50 total points
ID: 17082970
UPDATE table2
SET name = b.name
FROM table2 a INNER JOIN table1 b ON a.id = b.id
WHERE a.name IS NULL
0
 

Author Comment

by:Zeman4323
ID: 17083015
Perfect!


Thanks so much
0

Featured Post

Backup Solution for AWS

Read about how CloudBerry Backup fully integrates your backups with Amazon S3 and Amazon Glacier to provide military-grade encryption and dramatically cut storage costs on any platform.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

JSON is being used more and more, besides XML, and you surely wanted to parse the data out into SQL instead of doing it in some Javascript. The below function in SQL Server can do the job for you, returning a quick table with the parsed data.
I have a large data set and a SSIS package. How can I load this file in multi threading?
Using examples as well as descriptions, and references to Books Online, show the documentation available for datatypes, explain the available data types and show how data can be passed into and out of variables.
Viewers will learn how to use the SELECT statement in SQL to return specific rows and columns, with various degrees of sorting and limits in place.

761 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