1

There are two table, also two column are the same between them

table1:
id, date

table2:
id, date

The problem is , how to update the id of table 2 that can match the date in 2 table , that means, e.g.

update table2 set table2.id = table1.id Where table1.date = table2.date

thanks

Prahalad Gaggar
  • 11,389
  • 16
  • 53
  • 71
user782104
  • 13,233
  • 55
  • 172
  • 312

1 Answers1

3
update t2 set t2.id = t1.id 
from table2 t2
inner join table1 t1 on t1.date = t2.date

Edit

update t2 set t2.id = t1.id 
from table2 t2
inner join table1 t1 on t1.date = t2.date
where convert(date,t2.date)>'2013/01/01' --YYYY/MM/DD if your Date column is datetime.
Prahalad Gaggar
  • 11,389
  • 16
  • 53
  • 71