sql 数据库表数据转移

一、如果另一个库中没有同名的表

select * 
into b数据库.dbo.a表 
from a数据库.dbo.a表 
where 条件

 

二、如果是追加到另一个表中

inert into [b数据库].dbo.a表(字段)
select * 
from [a数据库].dbo.a表 
where 条件

例子:把【本库表A 】比 【库B表A】 多的数据填充到 【库B表A】

insert into [Data001].dbo.Period
select a.*
from Mall_Period a
left join [Data001].dbo.Period b on a.ID = b.ID
where b.ID is null

 

转载于:https://www.cnblogs.com/acchu/p/9986852.html