表/复制表
在sql server 2005数据库操作中经常复制一张表,用于临时操作;
普通的方法是:
建立一张一样的表,然后插入记录,这样速度太慢了,用select语句可以很方便
1.复制表头
select * into table_copy from table where 1<>1 --(只要条件为false)
select top 0 * into table_copy from table
2.表头和信息一起复制:
select * into table_copy from table
3.复制内容:要求两张表列类容必须是一样
insert into table_copy select * from table
4.要是经常操作,那么可以写个存储过程:
╮(╯▽╰)╭