[转]跨库数据表复制

use 目的库
go
 ----删除原表
if exists(select name from sysobjects where type='u' and id=object_id('表名'))
drop table 表名

go

use 源库
go

select * into 目的库.dbo.表名 from 表名

go

---从源表插入到目的表,A源库a表,B目的库b表.
---实现把a表的D字段内容复制到b表的C字段
Use A
go
insert B.dbo.b(C) select D from a




select * into 目的库.dbo.表名 from 表名 where 1=1 复制表结构与内容
select * into 目的库.dbo.表名 from 表名 where 1=0 只复制表结构

posted @ 2009-05-30 15:19  夜半松风  阅读(250)  评论(0)    收藏  举报