select into 语句数据表全表复制备份
select into 语句常用于创建表的备份复件或者用于对记录进行存档。
sql select into 语法
您可以把所有的列插入新表:
select *
into new_table_name [in externaldatabase]
from old_tablename
或者只把希望的列插入新表:
select column_name(s)
into new_table_name [in externaldatabase]
from old_tablename
实例
下面的语句表明在跨但是去掉自增长列执行没有问题
select * into #tbranch from test.dbo.tb_test ts
--下面的语句表明在同一个数据库内执行没有问题
select identity(int,1,1) as [newid],* into #tbranch from tb_test
制作备份复件
下面的例子会制作"persons"表的备份复件:select * into persons_backupfrom persons
in子句可用于向另一个数据库中拷贝表:select persons.* into persons in 'backup.mdb'from persons
如果我们希望拷贝某些域,可以在select语句后列出这些域:select lastname,firstname into persons_backupfrom persons
你也可以添加where子句。下面的例子通过从"persons表中提取居住在"sandnes"的人的信息&