SQLServer 复制表结构

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 on 2022-09-28 11:37  静以修身俭以养德  阅读(1357)  评论(0编辑  收藏  举报

导航