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
 table's data updation

Author  Topic 

mr_dayal
Starting Member

37 Posts

Posted - 2008-07-03 : 03:34:08
I have two tables

Table1

Id Code
_____________________ ________
JC/HL/SIL/S2/STOL0007 STOL0007
JC/HL/COT/P2/PLAI0008 PLAI0008
JC/HL/COT/P2/RANG0002 RANG0002
JC/HL/COT/B2/PLAI0001 PLAI0001
JC/HC/C/B4/BAND0001 BAND0001
JC/HL/COT/B2/DESI0001 DESI0001


and table2
Id Code
_____________________ ________
JC/HL/SIL/S2/STOL0007
JC/HL/COT/P2/PLAI0008
JC/HL/COT/P2/RANG0002
JC/HL/COT/B2/PLAI0001
JC/HC/C/B4/BAND0001
JC/HL/COT/B2/DESI0001



Now I want to update code field of table2 with the same data as in code column of table1.. How Will i do that?

Mr Dayal

RickD
Slow But Sure Yak Herding Master

3608 Posts

Posted - 2008-07-03 : 03:37:14
update table2
set code = t1.code
from table1 t1
inner join table2 t2
on t1.id = t2.id
Go to Top of Page
   

- Advertisement -