Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

update a table with a column from another table

Status
Not open for further replies.

jlt1

Programmer
Jun 20, 2002
4
0
0
GB
Hi can anyone help me. I am using MS SQL 2000. In my database I have a table say table1 with three columns a, b and c. Columns a and b have 20 rows with data whilst c has 20 empty rows (with null data). I have a second table - table2 with a column c. How can I best update table1 so that data from column c in table 2 replaces the null rows in table1 column c (without appending additional rows.)
Many thanks from an sql novice.
 
Do the rows in the tables have related columns? Assuming columns a and b are related, the following example should help you get started.

Update Table1
Set c = table2.c
From Table1
Inner Join Table2
On Table1.a=Table2.a
And Table1.b=Table2.b Terry L. Broadbent - DBA
Computing Links:
faq183-874 contains "Suggestions for Getting Quick and Appropriate Answers" to your questions.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top