MSSQL复制表操作

1:复制表结构及数据到新表

select * into 目的数据库名.dbo.目的表名 from 原表名

select * into my0735home.dbo.infoMianTest from infoMian

2:备份表的一部分列(不写*而写出列的列表)

select 列名1,列名2,列名3 into 目的数据库名.dbo.目的表名 from 原表名

select id,title,mtype,stype,author,tel,nr into infoMianTest2 from infomian

3:备份表的一部分行(加WHERE条件)

select * into 目的数据库名.dbo.目的表名 from 原表名 where id<10

select * into infomiantest2 from infomian where id<10

4:备份表的一部分列(不写*而写出列的列表)和一部分行(加WHERE条件)

select 列名1,列名2,列名3 into 目的数据库名.dbo.目的表名 from 原表名 where  id<10

5:只复制表的结构:如:SELECT * INOT t1 FROM titles WHERE 1=2

6:查询结果来源于多个表:如:

SELECT title_id,title,pub_name INTO t3

FROM titles t INNER JOIN publishers p

ON t.pub_id=p.pub_id

posted @ 2016-05-17 21:14  Jacky's Blog  阅读(1990)  评论(0编辑  收藏  举报