【SQL Server】将查询结果插入到另一个表

  1. 查询结果插入新表
    select * into tableA from tableB where …

  2. 查询结果插入已经存在的表
    insert into tableA
    select * from tableB where…

  3. 查询结果跨数据库
    insert into schemaA.tableA
    select * from schemaB.tableB where…

  4. 查询结果加上新字段插入已经存在的表
    insert into tableA
    select *,NULL from tableB where…

欢迎关注微信公众号:516数据工作室
516数据工作室

猜你喜欢

转载自blog.csdn.net/Asher117/article/details/84938375