将一个数据库中的表复制到另一个数据库中,只需要复制一部分内容,两个数据库在同一服务器中!

表不存在的情况下
select 字段1,字段2.....字段n into 数据库名..新表名 from 旧数据库名..旧表 where 条件

表存在的情况下
insert into 数据库名..新表名 select select 字段1,字段2.....字段n from 旧数据库名..旧表 where 条件
select * into 数据库.dbo.新表名  from  数据库.dbo.要复制的表



select * into OA5..SL_AskedForLeaveType from OA..SL_AskedForLeaveType


从另一个数据库表提供的数据,更新当前数据库表的一列
update VocationalGuidance2..VGS_ResumeTemplate set TemplateContent=(select TemplateContent from [VGS_ResumeTemplate])

select * from  labsubject where ISNUMERIC (textbookid )=1

update labsubject set textbookid=(select bookname from yq_book where id=cast(textbookid as int)) where ISNUMERIC (textbookid )=1

原文地址:https://www.cnblogs.com/slyzly/p/2769350.html