1、说明:复制表(只复制结构,源表名:a 新表名:b)
法一:select * into b from a where 1<>1
例:把TblTeacher表复制到NewTeacher2
select * into NewTeacher2 from TblTeacher where 1<>1
法二:select top 0 * into b from a
例:
select top 0 * into NewTeacher3 from TblTeacher
--如果说表New3已经存在,就进行以下设置:
SET IDENTITY_INSERT NewTeacher3 ON
insert into NewTeacher3
SET IDENTITY_INSERT NewTeacher3 OFF
Sql如何相表里复制一条记录 复制整个表
例:
--这个语句从anothertable拷贝记录到mytable.只有表anothertable中字段another_first的值为‘Copy Me!’的记录才被拷贝
INSERT mytable (first_column,second_column)
SELECT another_first,another_second
FROM anothertable
WHERE another_first='Copy Me!
sql里面如何复制表结构和复制表?
例:
--建立新表a2并且复制a1表结构到a2
select top 0 * into a2 from a1
--a2表中插入与a1相同数据
insert into a2 select * from a1
--复制并插入数据
select * into a2 from a1select * from a2