复制表中数据和向表中插入多条记录

论坛 期权论坛 脚本     
匿名技术用户   2020-12-28 13:57   39   0
 --将TblStudent表中的所有数据拷贝到TblStudent2014新表中(TblStudent2014表之前不存在)只拷贝原表中
 --数据,表中的约束不拷贝。select into语句不能重复执行,因为每次执行都会创建一个新表
   select * into TblStudent2014  from TblStudent 
 
 --只拷贝表中的结构,不拷贝表中的数据
   select top 0 * into TblStudent20140506Backup from TblStudent

--使用insert into 表 select.....from 表,向原来已存在的表中插入选择的数据,
--TblStudent20140506Backup表原来已存在,将TblStudent表中所选择的列的数据全部插入原来已存在的表中
insert into  TblStudent20140506Backup select tsname,tsgender,tsaddress from TblStudent where
tsgender = '女'
insert into OrderSchedule(orderstartdate,ordernumber) select  orderdate, ordernumber from OrderDetails -- 向OrderSchedule中插入OrderDetails表中所选择的列的数据

分享到 :
0 人收藏
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

积分:7942463
帖子:1588486
精华:0
期权论坛 期权论坛
发布
内容

下载期权论坛手机APP