当前位置: 移动技术网 > IT编程>数据库>MSSQL > sql复制表结构和数据的实现方法

sql复制表结构和数据的实现方法

2017年12月12日  | 移动技术网IT编程  | 我要评论

打击北京第五季幸福城,时尚秀足网,cfawm天龙

sql server中使用select … into语句

按照使用场合可以分为以下几类:

1. 实现全表备份:如:select * inot t1 from titles

2. 备份表的一部分列(不写*而写出列的列表)或一部分行(加where条件)

如: select title_id,title,price into t2 from titles—部分列

select * into t2 from titles whree price>10 –部分行

select title_id,title,price into t2 from titles whree price>10 –部分行和部分列

3. 只复制表的结构:如:select * inot t1 from titles where 1=2

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

select title_id,title,pub_name into t3

from titles t inner join publishers p

on t.pub_id=p.pub_id

5.select * into 要复制到的数据库名.dbo.表名 from 原数据库名.dbo.表名

如对本文有疑问,请在下面进行留言讨论,广大热心网友会与你互动!! 点击进行留言回复

相关文章:

验证码:
移动技术网