farris
farris

Reputation: 11

update one table by inserting values from another table SQL server

I have two tables bottle and case that are filled out. They both have a column labeled case_id however in bottle table all the values are 0 while in case table they have the correct id.

How can I update the first table bottle values 0 with the new values from other table case? I believe I will need to use an UPDATE or INSERT or INNER JOIN.

Upvotes: 0

Views: 63

Answers (1)

Nolan Shang
Nolan Shang

Reputation: 2328

If you give more detail for table struct will be better

UPDATE b SET b.case_id=c.case_id
FROM bottle AS b INNER JOIN [Case] AS c ON b.some_coloumn=c.some_cloumn

Upvotes: 1

Related Questions