題目如下:

Table1 裡有id ,date 兩個字段

Table2 裡有id,date 兩個字段

table1datetable2date相等時,把table2id的值更新到table1id去。

答案:
update table1 set id=b.id  from table1 a, table2 b where a.data=b.data

 
另外成批插入語句:
insert into table1 (date) (select date from table2)

成批更新time表字段
update time set the_year=year(the_date),the_month=month(the_date),
the_quarter=DATEPART(qq,the_date),the_week=DATEPART(wk,the_date),the_day=day(the_date)

相关文章:

  • 2021-09-30
  • 2022-01-17
  • 2021-08-12
  • 2021-09-26
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2022-01-29
  • 2021-12-29
  • 2021-12-19
  • 2022-01-13
  • 2021-08-21
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案