insert into 的用法,我想将一个表中的数据导入到一个自定义的表中

来源:百度知道 编辑:UC知道 时间:2024/05/29 12:35:58
insert into
A表中的数据复制一份到B表。删除A表里的数据再将B表里的数疽导入A表中去

假设两表结构相同:
insert into b select * from a
delete a
insert into a select * from b

Insert Into的用法总结
1、将一张表的信息插入到另一张表中例子:
Insert Into tt
Values(id,title,pubtime)
select id,title,pubtime
from ww
where id = '0001'

2、用 VALUES 子句为一行指定数据值:
INSERT INTO MyTable (PriKey, Description)
VALUES (123, 'A description of part 123.')

用 SELECT 子查询为一行或多行指定数据值。
INSERT INTO MyTable (PriKey, Description)
SELECT ForeignKey, Description
FROM SomeView

3、循环插入数据
DECLARE @MyCounter INT

SET @MyCounter = 0 /*设置变量*/

WHILE (@MyCounter < 2) /*设置循环次数*/

BEGIN

WAITFOR DELAY '000:00:10' /*延迟时间10秒*/

INSERT INTO time_by_day

(time_id, the_date, the_year, month_of_year, quarter, day_of_month)

SELECT TOP 1 time_id + 1 AS time_id, the_date + 1 AS the_date, YEAR(th