Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 How to update table1 from table2

Author  Topic 

Vaishu
Posting Yak Master

178 Posts

Posted - 2007-11-22 : 09:37:15
Hi

I have table1 with tow columns ( col1 and col2)
table2 colums (col1 and col2)

Table1 -- col1--- col2
-----------A ---- dfg
-----------B ---- ght

Table2-- Col1--- col2
-----------A ----- jjk
-----------B ----- lkl


How do I update col2 of Table1 with the data from col2 of Table2 in a Single Query

suresha_b
Yak Posting Veteran

82 Posts

Posted - 2007-11-22 : 09:49:02
update t1
set col2 = t2.Col2
from Table1 t1
inner join Table2 t2
on t2.col1 = t1.col1
Go to Top of Page

harsh_athalye
Master Smack Fu Yak Hacker

5581 Posts

Posted - 2007-11-22 : 09:49:24
[code]Update t1
set Col2=t2.Col2
From Table1 t1 join Table2 t2 on t1.Col1 = t2.Col1[/code]

Harsh Athalye
India.
"The IMPOSSIBLE is often UNTRIED"
Go to Top of Page

Vaishu
Posting Yak Master

178 Posts

Posted - 2007-11-22 : 09:55:06
Thank you very much for swift replies.
Go to Top of Page
   

- Advertisement -