在sql SERVER中使用SELECT … INTO语句可以实现把查询结果存入新表,具体实现分为以下几种情况:
1、全表备份。
例如:select * into newtable from oldtable;2、备份表中的部分字段。
例如:select ID,name,price into newtable frome oldtable;
select * into newtable from oldtable where price > 100;
select ID,price into newtable from oldtable where price > 100;3、只复制表的结构。
例如:select * into newtable from oldtable where 1 = 2;4、查询结果来自多个表。
例如:select oldtable1.ID,oldtable1.name,oldtable2.datatime into newtable
from oldtable1,oldtable2
where oldtable1.name = oldtable2.name;select oldtable1.ID,oldtable2.datatime into newtable
from oldtable1 as t1 inner join oldtable2 as t2
on t1.name = t2.name; 5、select * into 要复制到的数据库名.DBO.表名 from 原数据库名.DBO.表名 总结以上是内存溢出为你收集整理的在SqlServer中将查询结果存入新表全部内容,希望文章能够帮你解决在SqlServer中将查询结果存入新表所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)